Regex again (string between first and last underscore)

Post Reply
magnussandstrom
Member
Posts: 56
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden

Regex again (string between first and last underscore)

Post by magnussandstrom » Mon Jun 14, 2021 8:56 am

Hi, in a Switch variable I would like to capture the string between the first and last underscore, without including the underscores. But since switch don't support lookahead/lookbehind (or groups?) I would need som help.

Original string: 1234abc_This_is_the_text_I_want_1234abc

I want the result: This_is_the_text_I_want

But with _(.*)_ I get the result: _This_is_the_text_I_want _

I would like to use (?<=\_)(.*?)(?=\_) but thats not supported.

Any suggestions?
Tools at hand: Enfocus Switch, Esko Automation Engine, Esko Imaging Engine, Apogee Prepress, HP DFE, Fiery, Caldera, GMG ColorProof, PressSign, Redhat FUSE, Microsoft Azure and Google Cloud Services.

freddyp
Advanced member
Posts: 623
Joined: Thu Feb 09, 2012 3:53 pm

Re: Regex again (string between first and last underscore)

Post by freddyp » Mon Jun 14, 2021 11:19 am


magnussandstrom
Member
Posts: 56
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden

Re: Regex again (string between first and last underscore)

Post by magnussandstrom » Mon Jun 14, 2021 1:03 pm

I tried the stringsplitter app but it devides the string in separate parts devided by underscore (in this case), but I don't want to separate the middle section (after the first underscore til the last underscore) if it also contains underscores.
Tools at hand: Enfocus Switch, Esko Automation Engine, Esko Imaging Engine, Apogee Prepress, HP DFE, Fiery, Caldera, GMG ColorProof, PressSign, Redhat FUSE, Microsoft Azure and Google Cloud Services.

magnussandstrom
Member
Posts: 56
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden

Re: Regex again (string between first and last underscore)

Post by magnussandstrom » Mon Jun 14, 2021 1:07 pm

A regex app that can fully utilise regular expression functions would be great! Ping @appdevs :) Unless it's added in a future Switch release.
Tools at hand: Enfocus Switch, Esko Automation Engine, Esko Imaging Engine, Apogee Prepress, HP DFE, Fiery, Caldera, GMG ColorProof, PressSign, Redhat FUSE, Microsoft Azure and Google Cloud Services.

Arthur
Member
Posts: 105
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: Regex again (string between first and last underscore)

Post by Arthur » Mon Jun 14, 2021 3:04 pm

It has been queried many times over since at least 2017 release of Switch, yet seemingly not enough needed, since it has not been implemented in full yet.
They know of this being useful to have full Regex in Switch, but it is not easy to get it implemented apparently. I mean, this is what I was told in 2019 in London on one of the Enfocus days or whatever it was called.
I am guessing - the more voices behind this, the more likely they will be looking into it.

Post Reply