Skip to main content
Solved

RegEx TestFilter

  • July 8, 2015
  • 7 replies
  • 406 views

jelle
Contributor
Forum|alt.badge.img+21
  • Contributor
  • 122 replies
Hi Community, 

 

 

I have an issue using RegEx in the TestFilter. This is what I do:

 

 

 

 

It never returns any result.

 

 

However, when I use the StringSearcher to do the same, The RegEx works well:

 

 

 

 

Any idea what I'm doing wrong in the TestFilter? According to this article: https://knowledge.safe.com/articles/Error_Unexpected_Behavior/Regular-expressions-that-work-in-one-parameter-fail-in-another, the implementation is indeed different. However, the two websites for testing RegEx mentioned in the article resolve the RegEx well.

 

 

How should the 'Right Value' be defined in the TestFilter?

 

 

 

best regards, 

 

Jelle

Best answer by takashi

Hi Jelle,

 

 

I think the StringSeacher tests the regex with partial matching but the TestFilter tests it with entire matching.

 

Try this expression for the Right Value in the TestFilter.

 

-----

 

.*(EXAVB|EXVB|EVAVB).*

 

-----

 

In addition, the "Matches Regex" operator seems to always work with case-sensitive mode.

 

 

Takashi
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.

7 replies

takashi
Celebrity
  • 7843 replies
  • Best Answer
  • July 8, 2015
Hi Jelle,

 

 

I think the StringSeacher tests the regex with partial matching but the TestFilter tests it with entire matching.

 

Try this expression for the Right Value in the TestFilter.

 

-----

 

.*(EXAVB|EXVB|EVAVB).*

 

-----

 

In addition, the "Matches Regex" operator seems to always work with case-sensitive mode.

 

 

Takashi

jelle
Contributor
Forum|alt.badge.img+21
  • Author
  • Contributor
  • 122 replies
  • July 8, 2015
Hi Takashi, 

 

 

thank you for your answer. Following is already sufficient in the TestFilter:

 

-----

 

EXAVB|EXVB|EVAVB.*

 

-----

 

 

 

best regards, 

 

Jelle

 

 

 

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • March 16, 2016

Hi @jelle and @takashi

Just to let you know some good news. All of the regex transformers in FME 2016.1 should be working the same way from now on which is as it was working in the StringSearcher. The terminology in regex parameters has been changed to read "Contains Regex". For example if the expression ^a is used it will now match the string abracadabro and @jelle's example will now work as is once the transformer is upgraded.


takashi
Celebrity
  • 7843 replies
  • March 16, 2016

Hi @jelle and @takashi

Just to let you know some good news. All of the regex transformers in FME 2016.1 should be working the same way from now on which is as it was working in the StringSearcher. The terminology in regex parameters has been changed to read "Contains Regex". For example if the expression ^a is used it will now match the string abracadabro and @jelle's example will now work as is once the transformer is upgraded.

Hi @kenbragg, thanks for the information. I noticed the change just a few days ago, with 2016.1 beta. It's a quiet but definitely great enhancement.


Forum|alt.badge.img
  • 4 replies
  • February 2, 2017

Hi,

@takashi Do you know why the Matches Regex operator is always case-sensitive and if there is a way around this? We got caught out with this since in the Regular Expressions Editor it says it is Case-Insenstive, and is insensitive in the Test String, but for actual transformer it becomes case sensitive!

Thanks


takashi
Celebrity
  • 7843 replies
  • February 2, 2017

Hi,

@takashi Do you know why the Matches Regex operator is always case-sensitive and if there is a way around this? We got caught out with this since in the Regular Expressions Editor it says it is Case-Insenstive, and is insensitive in the Test String, but for actual transformer it becomes case sensitive!

Thanks

In FME 2016.1, the Matches Regex operator has been replaced with the Contains Regex operator, and the new operator can also be used to determine partial match. It was a good enhancement but the case sensitivity has not changed. As you mentioned, the operator always still works in case-sensitive and there seems to be no option to change the behavior, although the regex editor works in case-insensitive mode.

 

I already reported to Safe support about the inconsistency between the actual behavior of the operator (case-sensitive) and the regex editor for the operator (case-insensitive), at last March (C113393, PR#69263). It has not been resolved yet in FME 2017 RC :-(

 

I'm wondering if there is a special reason why they don't fix that. So difficult? > @NatalieAtSafe

Forum|alt.badge.img+2
  • 1891 replies
  • February 13, 2018

Changes in FME 2018 should also make conditional tests more consistent for case sensitivity throughout FME. For example, if you add a Tester in 2018, the Mode option allows you to select the test mode - numeric , case sensitive, case in- sensitive . We also added a date/time mode so you can run conditional tests against the the FME date/times

Hopefully this will help you in future FME projects.