Solved

RegEx TestFilter


Badge +11
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
icon

Best answer by takashi 8 July 2015, 12:23

View original

7 replies

Userlevel 2
Badge +17
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
Badge +11
Hi Takashi, 

 

 

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

 

-----

 

EXAVB|EXVB|EVAVB.*

 

-----

 

 

 

best regards, 

 

Jelle

 

 

 
Userlevel 4
Badge +13

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.

Userlevel 2
Badge +17

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.

Badge

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

Userlevel 2
Badge +17

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
Badge +2

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.

Reply