Skip to main content

Hi, I would like to know hot to define the texts beginnig and end.

I have got :

 

Attribute: Adressen_kalkuliert_drop_loc

 

D-L-143245-143245-F-45--1xMICRO-DUCT-12x10-6MM

D-F-422-F-471--1xMICRO-DUCT-12x10-6MM

(a tousands of them)

 

and need to define Attribute Value:

 

L-143245 (from the first one) and

F-422 (from the second one)

 

the texts are always different, and have a different number of numbers

But beginns alway with "F", or "L" and ends always with "-" behind the number.

 

thanks

 

You can try a StringSearcher with the regular expression [L|F]-\\d+ but on both lines of sample text it will actually match more than just that. If you create a list of matches and grab the first item it will probably be what you want.

For more security, try the regular expression ^D-[L|F]-\\d+ and then a StringReplacer afterwards to replace regex ^D- with nothing.


You can try a StringSearcher with the regular expression [L|F]-\\d+ but on both lines of sample text it will actually match more than just that. If you create a list of matches and grab the first item it will probably be what you want.

For more security, try the regular expression ^D-[L|F]-\\d+ and then a StringReplacer afterwards to replace regex ^D- with nothing.

Perfekt! It worked great!

Thanks a lot


You can try a StringSearcher with the regular expression rL|F]-\d+ but on both lines of sample text it will actually match more than just that. If you create a list of matches and grab the first item it will probably be what you want.

For more security, try the regular expression ^D-oL|F]-\d+ and then a StringReplacer afterwards to replace regex ^D- with nothing.

A small correction. tL|F] matches not only L or F but also | (pipe), so this expression would be better.

ÂLF]-\d+
or
(L|F)-\d+

A small correction. .L|F] matches not only L or F but also | (pipe), so this expression would be better.

tLF]-\d+
or
(L|F)-\d+

Thanks for catching that, I *thought* I knew a bit about regexes... 


Reply