This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
We have extended our Early Bird Tickets for Inspire 2023! Discounted pricing goes until February 24th. Save your spot!
(-|X|D|R)(.*) |
String | RegExOut1 | RegExOut2 |
195/75D14 | D | 14 |
7-14.5 | - | 14.5 |
7.00-14 | - | 14 |
7.00-14 | - | 14 |
7.50-15 | - | 15 |
7.50-17 | - | 17 |
10.5/80-18 | - | 18 |
10/10.5-20 | - | 20 |
1050/50R32 | R | 32 |
10X61X5 | X | 61X5 |
10X9X100 | X | 9X100 |
Desired | |
RegExOut1 | RegExOut2 |
D | 14 |
- | 14.5 |
- | 14 |
- | 14 |
- | 15 |
- | 17 |
- | 18 |
- | 20 |
R | 32 |
X | 5 |
X | 100 |
Returns NULLs: | \>(-|X|D|R)(.*) |
Returns NULLs: | (-|\>X|D|R)(.*) |
Solved! Go to Solution.
if the second part always is number. you can try to use [\d\.] (any character is number or dot) and $ (refer to the end of the string)
(-|X|D|R)([\d.]+)$
This will give you 3 fields, but does what you want to do 🙂
(-|X|D|R)(?!.*(-|X|D|R))(.*)$
Hi @bmalak_98,
You could use something along these lines:
.*?([a-z])?([\d\.]+)$
The dollar sign anchors the regex to the end of the string so you're searching for the last iteration of a character a-z (which could or may not be there) followed by the last number (including decimal places)
I've attached my workflow for you to download if needed!
Kind regards,
Jonathan
Thank you, @Pang_Hee_Choy.
That works well.
Thank you, @cmcclellan.
I can use that as a solution.
Thank you, @Jonathan-Sherman
That works great.
I've incorporated bits and pieces from all the responses so far and have settled on the
(-|X|D|R)([\d.]+)$
just in case the number is more than 1000 and have thousand separator (,).
you may add a comma in the [\d.]
(-|X|D|R)([\d.,]+)$
Thank you for the update.