Skip to main content
Question

Search and replace


I would like to search a string for the text (example HIGHWAY1 & HIGHWAY6 or HIGHWAY11 and replace it with 1 HWY & 6 HWY or 11 HWY)

6 replies

david_r
Evangelist
  • July 25, 2017

Try this in a StringReplacer:


trentatsafe
Safer
Forum|alt.badge.img+6

You could also use a ReplaceText mode StringReplacer,although @david_r regular expression works just as well.

 

 

Here is an example using the Replace Text mode if you wish:

 


david_r
Evangelist
  • July 25, 2017
trentatsafe wrote:

You could also use a ReplaceText mode StringReplacer,although @david_r regular expression works just as well.

 

 

Here is an example using the Replace Text mode if you wish:

 

Ah, I understood it as if the attribute would contain either "HIGHWAY1" or "HIGHWAY6", not the complete string "HIGHWAY1 & HIGHWAY6 or HIGHWAY11". Different approach :-)

  • Author
  • July 25, 2017
david_r wrote:

Try this in a StringReplacer:

 

Than you david_r I used your suggestion and I was able to get the results I was looking for.

  • Author
  • July 25, 2017
david_r wrote:
Ah, I understood it as if the attribute would contain either "HIGHWAY1" or "HIGHWAY6", not the complete string "HIGHWAY1 & HIGHWAY6 or HIGHWAY11". Different approach :-)
What it is, is any HIGHWAY with a number in it. In some cases it will be HIGHWAY# & HIGHWAY#. Your solution works now I dont have to do it manually. T

 

 


david_r wrote:

Try this in a StringReplacer:

2 questions!

 

 

1)

Can you please reference a page or link to better understand the expression/script being used here to <find the characters at the end of the HIGHWAY> (\\d+) and <insert those characters at the beginning of the replacement text> \\1 ?

 

 

2)

I'm curious also about the scenerio say:

 

I have a list of name and file path and I want to update the file path names in that list, so find characters within a list update a portion of that string... i.e:NamePathFile_1C:\\FMEData2019\\Output\\File1.txt

 

File_2C:\\FMEData2019\\Output\\File2.txt

 

 

etc..

 

 

and find the characters

"C:\\FMEData2019"

 

 

and change/replace to:

"C:\\FMEData2020"

The final output being:

The only portion of the path being changed is the first portion of the path

NamePathFile_1C:\\FMEData2020\\Output\\File1.txt

 

File_2C:\\FMEData2020\\Output\\File2.txt

 

 

(Not looking for all the readers and such, asking just about how the expression might work)

 

 

Thoughts? Thanks!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings