Reg ex tool not recognizing positive lookbehind
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am trying to use positive lookbehind in the RegEx tool to capture beginning of a string among other things. It looks like the part that is giving me an error is the part of the expression that is looking for the beginning of the string. I have tested the expression on two different RegEx pages online and it works. Why is Alteryx giving me an error?
I have attached a simple workflow that has some example data and that also shows where the error occurs.
Can someone please help? What is wrong with the expression?
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Eva
I think it was getting confused with the ^| meaning at the start of the string there's "nothing" option.
I usually use https://regex101.com/ and change the flavor to Python. I did this and changed your regex slightly and I get this
Hopefully that helps ::)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you for the quick reply. Unfortunately it does not really capture the problem. The change to the rex ex that you suggested kind of changed the syntax of what I want to capture. If you compare the expected values to the result you see that record 13 is wrongly included in the result.
The main part of the string that I want to capture has the syntax of “3 characters within A-Z followed by 5 to 7 digits”. That should be ok with this reg ex: [A-Z]{3}\d{5,7}
That main part must either be the start of the string or be preceded by either a slash, a dash or an underscore.
The main part can then be followed by either nothing, i.e. be the end of the string, or another slash.
What would the reg ex be to describe that and that also works in Alteryx? The reg ex I have works on both https://regexr.com and https://regex101.com but not in Alteryx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi, @Eva
Hi, I also found a similar problem a long time ago, we use a syntax that passes fine on RegEx101.com, but not in Alteryx, the reason is that it uses a simple parsing pattern, I now use a workaround syntax to get around this problem, and it works.
FYI:
(?:^|\/|-|_)([A-Z]{3}\d{5,7})(?=\/|$)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you flying008. That worked. 😀
