Skip to main content
Solved

RegEx bug in StringSearcher

  • February 16, 2022
  • 4 replies
  • 42 views

pflegpet
Contributor
Forum|alt.badge.img+8

Hi,

I think I found a super obscure bug in StringSearcher. In my workspace I want to use Regex queries based on different conditions, e.g. if a string matches RegEx A use RegEx B in StringSearcher. This logic does work in general but for one specific query I get the Error:

 

"Expression Evaluation Failure: 'This FME edition does not recognize the `' function."

 

Oddly the query works fine when I test it in the RegEx Editor. It also works if I don't use a condition or if I use a different query inside the condition. Is this a bug or am I missing something? Attached an example workspace that illustrates the issue. Thank you for your help!

 

Best answer by chrisatsafe

pflegpet wrote:

After some trial and error the escaped ")" inside the lookbehind seems to be the culprit: This lookbehind does not work: (?<=\)), I guess because of the double closed parentheses. When I replace the escaped ")" with another character like a "." it works fine. However this seems to only be an issue in combination with a condition. Would love to know if there is a way to make this work as intended. 

Interestingly the first time I tried running this in build 22278 (2022 beta) it failed with the same error message. Out of curiosity, I modified the regex from 

(?<=\))(\d|\-|\ )+

 to 

(?<=\))(\d|\-|\s)+

to see if it was just the space that was causing issues. Running with the whitespace character \s seemed to work. 

 

Even more interesting, when I set the Regex back to the original (?<=\))(\d|\-|\ )+ the workspace ran without any issues! After seeing that work, I tried adding a new StringSearcher in 22 and confirmed that it runs the first time with the original conditional statement. So the good news is, this is already fixed! Is running this workspace in FME 22 a suitable workaround for the time being? 

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

4 replies

pflegpet
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • February 16, 2022

After some trial and error the escaped ")" inside the lookbehind seems to be the culprit: This lookbehind does not work: (?<=\\)), I guess because of the double closed parentheses. When I replace the escaped ")" with another character like a "." it works fine. However this seems to only be an issue in combination with a condition. Would love to know if there is a way to make this work as intended.


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • Best Answer
  • February 17, 2022
pflegpet wrote:

After some trial and error the escaped ")" inside the lookbehind seems to be the culprit: This lookbehind does not work: (?<=\)), I guess because of the double closed parentheses. When I replace the escaped ")" with another character like a "." it works fine. However this seems to only be an issue in combination with a condition. Would love to know if there is a way to make this work as intended. 

Interestingly the first time I tried running this in build 22278 (2022 beta) it failed with the same error message. Out of curiosity, I modified the regex from 

(?<=\))(\d|\-|\ )+

 to 

(?<=\))(\d|\-|\s)+

to see if it was just the space that was causing issues. Running with the whitespace character \s seemed to work. 

 

Even more interesting, when I set the Regex back to the original (?<=\))(\d|\-|\ )+ the workspace ran without any issues! After seeing that work, I tried adding a new StringSearcher in 22 and confirmed that it runs the first time with the original conditional statement. So the good news is, this is already fixed! Is running this workspace in FME 22 a suitable workaround for the time being? 


pflegpet
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • February 17, 2022

Hi @chrisatsafe​,

thanks for looking into this issue. I still got the same error after updating to the newest version of FME 2021, but upgrading to FME 2022 fixed the issue for me as well. Fortunately I have a floating license so I can use both versions but maybe it would still make sense to create a bug report?


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • February 17, 2022
pflegpet wrote:

Hi @chrisatsafe​,

thanks for looking into this issue. I still got the same error after updating to the newest version of FME 2021, but upgrading to FME 2022 fixed the issue for me as well. Fortunately I have a floating license so I can use both versions but maybe it would still make sense to create a bug report?

In this case, it doesn't seem like the fix will be backported to 2021 since it's already in the 2022 beta.


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