Skip to main content
Solved

replace text with regex

  • June 4, 2015
  • 5 replies
  • 42 views

tva
Contributor
Forum|alt.badge.img+13
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
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, 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+46
  • 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+13
  • 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+46
  • 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+13
  • 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...