Inconsistent results from Regular Expression (Regex)

I’m having difficulty understanding the regex functionality. I have created a simple list with default values to try to isolate the issue and am getting some very unexpected results. The list is:

  1. One Cow
  2. Two
  3. Eleven sheep and a pig
  4. Four on it’s own
  5. Five

If I put .*sheep into the variable for regex sometimes row 3 is found, sometimes not. I am also having difficulty getting some standard functions to fun at all - the ^ symbol seems never to work properly.

Is there some specific way of entering WF regex statements that are different to normal? I am testing all my conditions on regex101.com and confirming that the behaviour is as expected.

Any help much appreciated, especially a code snippet. It’s driving me MAAAD!!! :confounded:!

@Bonnero
Hi Owen,
According to your regex on the screenshot, row 3 shouldn’t be found, as the string should end with sheep.
For this text, you should use expression .*sheep.*

Could you please share an example where ^ doesn’t work? Maybe, there is a mistake somewhere else in the expression?

Also, you can check out this thread for more info about regex: Text Actions - RegEx help

Thanks Alesia,
So now I understand what the issue is:

  • In the online Regex helpers, such as RegexOne.com and Regex101.com a phrase in the middle of a string will be matched without specifying anything past the matching portion. So, if I have a phrase “'Eleven sheep and a pig” the online regex tools will show a match for *.sheep whereas Sunbird requires a further specification past the end of the string to be matched and will only return correctly for *.sheep.*

  • This issue is the same for all expressions including the ^ expression so you will also not get a match for ^Eleven but instead must specify ^Eleven.*

  • Finally, as regards the inconsistency of outputs it may well be related to my poor syntax. I will keep an eye on it and repost if I can see something not working but right now I can’t reliably repeat the problem (which usually means I’m the problem!!!)

Thanks for the help - in summary, use good practice and specify all the way to the end of the string!

2 Likes

Correct, it is better to adhere to the strict rules.
Let us know if you have any other issues with regex.