Skip to main content
Solved

String Searcher and Regular expression

  • January 28, 2019
  • 1 reply
  • 189 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.

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.

1 reply

takashi
Celebrity
  • 7843 replies
  • 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.