Skip to main content

Hello,

I am trying to modify the contents of a series of json files, though I only need to remove all of the leading text before the "{"rings"" text. I will have upwards of 130 files to go through, and each has slightly different text to remove. I was thinking of using a StringReplacer to find all the text that I want to remove, then just set the "Replacement Text" to nothing. I'm assuming I need to use regex in the StringReplcaer to identify the series of text in each file that I need to remove. The example of text that I need to remove is:

{"displayFieldName":"","fieldAliases":{"OPS_AREA":"OPS_AREA","OBJECTID":"OBJECTID"},"geometryType":"esriGeometryPolygon","spatialReference":{"wkid":102100,"latestWkid":3857},"fields":[{"name":"OPS_AREA","type":"esriFieldTypeString","alias":"OPS_AREA","length":50},{"name":"OBJECTID","type":"esriFieldTypeOID","alias":"OBJECTID"}],"features":[{"attributes":{"OPS_AREA":"WINCHESTER","OBJECTID":12},"geometry":

though the "OPS_AREA" and "OBJECTID" values change between each file (obviously making the length of text I want to remove different between files). I am quite a noob on the regex front so I tried a number of things but really don't even have a clue as to what the syntax would be to remove this. I was thinking of using a StringReplacer to find all the text that I want to remove, then just set the "Replacement Text" to nothing.

I'm not opposed to using json readers or transformers either, but ultimately the output I need is just a text file with all the "rings" values (this specifically formatted text gets loaded into another database).

Any help would be greatly appreciates! Full disclosure - still using FME 2012!

Thanks

Tim

Hi @timboberoosky, this regex matches one or more characters before '{"rings"'.

.+(?={"rings")

This worked in FME 2013+ (I don't have FME 2012 installation).

See here to learn more about the syntax: Regular-Expressions.info | Positive and Negative Lookahead


Thank you very much, this works perfectly!


Reply