regex: Lookbehind not supported?

Post Reply
Joerg Schober
Member
Posts: 30
Joined: Mon Mar 21, 2011 2:30 pm

regex: Lookbehind not supported?

Post by Joerg Schober »

Hi,

trying to add hierarchy. For this, I try to extract "SA" from jobname

D_SA_1040.pdf



The used regex is

(?<=[a-zA-Z]{1}_)[a-zA-Z]{2}



It does not work. Is lookbehind supported by Switch?



Kind regards,

Jörg
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

regex: Lookbehind not supported?

Post by freddyp »

Lookbehind is indeed not supported.



I assume you are using this regular expression in the Search field of the Job.NameProper variable. There Switch only matches the first occurrence, so [a-zA-z]{2} would also return SA.



Freddy
Joerg Schober
Member
Posts: 30
Joined: Mon Mar 21, 2011 2:30 pm

regex: Lookbehind not supported?

Post by Joerg Schober »

Thanks Freddy for the reply.



There are also other filenames that are different (SE_MM_1804, ...), so the regex needed in production enviroment is

(?<=[a-zA-Z]{1,2}_)[a-zA-Z]{2}



How could i solve this issue. Is a script expression possible?

Supports javascript lookbehind (with variable length)?

It seems most languages only supports lookbehind (if they supports) with fixes length.



Kind regards,

Jörg


ArielRauch
Advanced member
Posts: 231
Joined: Thu Aug 07, 2014 10:04 am

regex: Lookbehind not supported?

Post by ArielRauch »

If I understand correctly you want to extract the different segments of the name. Should not be a a problem in a script expression.



Nameproper.split("-")



Or did I misunderstand you
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

regex: Lookbehind not supported?

Post by dkelly »

Joerg Schober wrote: try to extract "SA" from jobname

D_SA_1040.pdf


A script expression to retrieve "SA" part would be:



job.getNameProper().split("_")[1];
Post Reply