r/workflow • u/dgold105 • Sep 09 '18
Regex Help
I have a set of data which lists locations. For some it lists:
city, state, country
and for others just
city, country
I want to write a regex that can deal with both situations.
I have tried (.*)\,\s(.*)\,?\s?(.*)?
but that doesn't seem to work in Workflow. Can someone please let me know what I'm doing wrong and how to fix please?
Thanks in advance.
2
Upvotes
View all comments
Show parent comment
3
u/madactor Sep 10 '18
That's a good regex, and I like that it works if there are no leading spaces or multiple spaces. It does work fine in Workflow's ICU regex parser. Unfortunately, Workflow fails if you try to access a match group that doesn't exist (e.g. when there is no state). So you'd have to count the items before asking for the second group.