How to return more than one match with regex expression

470 Views Asked by At

Hi I am currently trying to use regex (in FME, using StringSearcher) to match and return every instance where there is a hashtag, and the 5 characters following it.

e.g "#29777 is close to #19666 and also make sure #12345 is there"

would return: "#29777 #19666 #12345"

I currently have this as my Regex expression which works, but i'm not sure how to get more than one return:

(?<=#).{5}

Any help would be greatly appreciated,

Thanks

2

There are 2 best solutions below

0
Carl Kristensen On

If you want to match hashtags with only 5 chars you can try this pattern:

#.{5}[\s]|#.{5}$
0
Sam Appleton On

I managed to get this working using regex from Carl Kristensen and a suggestion by booboo. The code still only returned the first match, but by populating all matches field and using a list exploder in FME, I was able to get all matches.

Thanks again for all of your help :)