I could use a little help with a regular expression.
The string I'm searching looks like this: "word1 word2 word3Number_number_1234". I need everything until (but NOT including) the last underscore.
This regEx
.*\_
will give me everything until and including the last underscore "word1 word2 word3Number_number_". How can I get rid of the last underscore?
Reg Ex help
- JimmyHartington
- Advanced member
- Posts: 312
- Joined: Tue Mar 22, 2011 7:38 am
Re: Reg Ex help
Hi Erik
I think you need to look into Lookahead and Lookbehind in RegEx.
I used a Lookahead in this test and it does the job. But I am not that strong in RegEx to say this is the best solution.
Read more here:
https://www.rexegg.com/regex-lookarounds.html
I think you need to look into Lookahead and Lookbehind in RegEx.
I used a Lookahead in this test and it does the job. But I am not that strong in RegEx to say this is the best solution.
Read more here:
https://www.rexegg.com/regex-lookarounds.html
Re: Reg Ex help
Thanks a lot, Jimmy. Works perfect
- JimmyHartington
- Advanced member
- Posts: 312
- Joined: Tue Mar 22, 2011 7:38 am
Re: Reg Ex help
Your welcome.
This trick is also good in InDesign as grep style to upper digits in m2 m3 og sup in CO2 and the like.
This trick is also good in InDesign as grep style to upper digits in m2 m3 og sup in CO2 and the like.