Skip to main content
Solved

how to define beginning and end of text

  • May 3, 2019
  • 4 replies
  • 14 views

terezia86
Forum|alt.badge.img

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

 

Best answer by redgeographics

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

redgeographics
Celebrity
Forum|alt.badge.img+62
  • Celebrity
  • Best Answer
  • May 3, 2019

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.


terezia86
Forum|alt.badge.img
  • Author
  • May 3, 2019

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


takashi
Celebrity
  • May 3, 2019

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.

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

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

redgeographics
Celebrity
Forum|alt.badge.img+62

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

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

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