Skip to main content
Question

StringSearch : use of non capturing group ?

  • September 4, 2020
  • 4 replies
  • 119 views

jedi121
Contributor
Forum|alt.badge.img+5

I'd like to use non capturing groups in StringSearch. It is possible in the PCRE expression but seems not to work in FME :

Example :

On the string "This is a text string"

(?:This is )(\\w)* should return only the string "a", but StringSearch returns the whole "This is a" in the "first_match", and only "a" in the subgroup when activated.

First match should be the same as the first subset ?

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.

4 replies

Forum|alt.badge.img+2
  • September 4, 2020

@jedi121​  StringSearcher is giving you the result you want, probably just not in the place that you'd expect find it. When you are using the regex editor in FME it shows all of the matched characters:

2020-09-04_14-47-41

Then in the StringSearcher parameters, you have to use the Advanced panel to generate a list of the sub-expressions that are to be captured;

2020-09-04_14-50-03

And then, you'll only see the results in Data Inspector / Visual Preview if you open the Feature Information window:

2020-09-04_14-51-53

Not to dissimilar to what https://regexr.com/ shows you - which is a great tool for testing and understanding regex expressions.


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • September 5, 2020

As @Mark Stoakes​ indicates, the return values for RegEx capable Transformers and Functions return the whole matching pattern as the default value to return, and not any particular group. This is why you get the full matching pattern back.

 

However, FME does support Groups in most RegEx Transformers and Functions, you just need to know how to call for the specific Group values. In FME, this is achieved by calling for the Group by writing "\\1" for Group 1's value and "\\2" for Group 2's value etc.

 

A general purpose way is to use StringReplacer. In the Replacement Text Parameter, if you instead use "\\1", then it will return the text within Group 1.

 

Similarly, using AttributeCreator with the String Function @ReplaceRegEx(@Value(TextAttributeToSearch), "(?:This is )(\\w)*", \\1), will return the first Group. Using @ReplaceRegEx(@Value(TextAttributeToSearch), "(?:This is )(\\w)*", \\2) will return the second Group etc.

 

 


aron
Enthusiast
Forum|alt.badge.img+16
  • Enthusiast
  • September 11, 2025

I got seriously stuck on this today. Took me a long time to figure out what was wrong. Would like to suggest a rework of this functionality so that it is less convoluted and works more intuitively. 


desiree_at_safe
Safer
Forum|alt.badge.img+16

Hi ​@aron
I understand that string manipulation can sometimes feel a bit tricky. The new AI Assist functionality is targeted to help make this process a little easier: https://fme.safe.com/platform/ai-assist/

However, it’s totally valid if AI Assist didn’t fully address or help your case or situation. If so, I’d really encourage submitting an IDEA here: https://community.safe.com/ideas

This way, other community members can vote on it and help motivate improvements to FME’s functionality and usability.

We really value feedback like this! It has made big differences 🙂