I've read through the RegEx mastery article, which has been very helpful, bit I've hit a wall. I'm trying to get quantities out of a text string, and it works for some entries, but not all. Particularly, where it doesn't work, it truncates the leading number. Can someone make a recommendation on where I'm going wrong with the parse and how I can correct for it?
Parse showing $1 in the first condition, and $2 in the second
(^\d+)|(^.*\s*)(\d+)
Data
String to parse | Desired outcome | Actual outcome |
24 sets per case | 24 | 24 |
6CS | 6 | 6 |
Widgets 1/CS | 1 | 1 |
Many Widgets 20/CS | 20 | 0 |
Few Widgets -20/Case | 20 | 0 |
Solved! Go to Solution.
Thanks Mark. Really appreciate the prompt reply! That works perfectly, as you pointed out, when there is only number.
Do you have any suggestions on what to do if there are multiple number sets in each input, but I'd always want to grab the last number set? For example, in both instances below, I'd want to return 50?
0.5 Parts 50/CS
8.5x11 size 50 box
@MarqueeCrew ... Your solution will get the very last digit. If you want the whole number I would do something like,
workflow
Thanks,
P
Spot on, @PhilipMannering ! Thanks so much. Works like a charm.
And thanks again @MarqueeCrew
Support here is awesome, thanks to people like the both of you.