Skip to main content
Solved

replace text with regex


tva
Contributor
Forum|alt.badge.img+12
  • Contributor
Hi,

 

 

I would like to change my string (which represents a uuid without dashes) to a uuid with dashes (8-4-4-4-12)

 

But I don't succeed. I know the regex to find the correct groups and a regex to replace with the dashes (found those in some forum for javascripters)

 

 

But if I use a string replacer and this regex to match my text : (\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})

 

and this regex to replace my text: \\$1-\\$2-\\$3-\\$4-\\$5

 

 

My string isn't replaced but it gets my replacement string

 

 

ex:

 

00000000000000000000000004040154 -> \\$1-\\$2-\\$3-\\$4-\\$5 instead of 00000000-0000-0000-0000-000004040154

 

 

And I don't find any other solutions via some other transformer

 

 

What should I do?

 

Thx

Best answer by ebygomm

If you wanted to use the string replacer, replacement text set as \\1-\\2-\\3-\\4-\\5  should also work
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • June 4, 2015
You could use an attribute splitter with format string set as 8s4s4s4s12s

 

Then a list concatenator with - as a seperator character

tva
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • June 4, 2015
Why did I make it so hard when it could be this simple :)

 

Thx for the quick reply

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • Best Answer
  • June 4, 2015
If you wanted to use the string replacer, replacement text set as \\1-\\2-\\3-\\4-\\5  should also work

tva
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • June 4, 2015
This one is even easier and made me think that I should look better at the help notes...

 

Flagged this one as best as it's better for me in my flow :)

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • June 4, 2015
You should always be aware of different flavours of regulasr expressions. What you did was correct, the syntax was not the one the engine uses when using StringReplacer transformer.

 

FME does some nice flavour mixing on itself btw...

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