RegEx match help
- 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
Hello, I'm trying to match an amount from the text with newlines, amount has leading currency symbol, so I'm trying to match based on that(in the string there are no other currency symbols. Example below.
" · CAD –> Main · EUR
€1 046.72"
" · CAD –> Main · USD
$1 533.18"
These are already simplified strings(right side that contains the amounts). This formatting is not universal. The only universal thing is that it's on the rightmost side of the string(before the newline or before end of the string)
Now for the frustrating part, this is the pattern that I'm using (([€\$]\s*)?\d{1,3}(?: \d{3})*(?:\.\d{2})\s*). I've tried adjusting it many times, and it shows in regex debugger(regex101) that it should catch those amounts just fine, but it doesn't catch in the alteryx(I'm using regex match function for it). Am I missing something? Is there an error in the pattern?
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Frndly
I've tried to tackle this problem using character sets. ([£€$][0-9\s\.]+)
This first looks for any character out of [£€$], and then it finds every occurrence of a number, space or decimal [0-9\s\.]+ after the initial currency symbol. By using the parse function in the regex tool, it should extract this value out.
Please let me know how you get on.
Regards - Pilsner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I think the issue is that you're not telling Alteryx to include the leading stuff in the match. In layman's terms, by adding "[\s\S]*?" to the front of your REGEX to get the new REGEX: [\s\S]*?(([€\$]\s*)?\d{1,3}(?: \d{3})*(?:\.\d{2})\s*) tells Alteryx that it's ok to have stuff in front of the match. For example, if my regex string was \d+ and I had the string "aa2", I normally wouldn't want that to match, whereas if I say [\s\S]*?\d+ then I'm telling the regex that it's ok to match the stuff in front.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you! This actually was the reason why regex match didn't work
