Skip to main content
Solved

String Searcher and Regular expression

  • January 28, 2019
  • 1 reply
  • 134 views

I'm not sure what words to use, again, to find my answer so I'm just going to ask.  I'm new to Regular Expressions, and not an FME wizard by any means

 

 

I need to, inside a loop,  take text that looks like this: (i'd like to avoid using blocking transformers if possible at this stage in my workbench)
OKC1D,790 [55559]|OKC1D, 791 [272]|OKC1D, 792|OKC1D, 796|XD, 4-6 [DEAD]

And make it look like this:


OKC1D,790 [5559]|OKC1D, 791 [272]|OKC1D, 792 [272]|OKC1D, 796 [272]|XD, 4-6 [DEAD]

 

With string replacers and searches I can get this:

OKC1D,790 [5559]|OKC1D, 791 [272]|OKC1D, 792|OKC1D, 796|

I'm able to select what's in the brackets with:

 

(?<=\[).*?(?=\])

 

but I get 5559 and 272,  I need a way to select the last matched group, 272, there are cases where it may be more than 2 match groups but I think that If I can just select the last one it should work

 

 

https://rubular.com/r/r2TsFBPPy19hFO

 

0684Q00000ArFUEQA3.png

 

 

Any regex wizards out there that may be able to help me, OR suggest a better way in FME to do what I want that will work inside a loop 

 

 

Thank you

Best answer by takashi

Hi,

If you set a list name (e.g. "_all") to the All Matches List Name parameter in the StringSearcher, '272' would be stored into the second element ("_all{1}.match") in the list.

View original
Did this help you find an answer to your question?

1 reply

takashi
Influencer
  • Best Answer
  • January 28, 2019

Hi,

If you set a list name (e.g. "_all") to the All Matches List Name parameter in the StringSearcher, '272' would be stored into the second element ("_all{1}.match") in the list.


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