You are viewing limited content. For full access, please sign in.

Question

Question

Need some helps about pattern matching (start, lookfor, End)

asked on May 28, 2018

Hi all,

 

I'm trying to make a pattern matching but I have 2 difficulties :

1. My search can have 1 or more lines,

          Example1 :

          Label: line1

or

          Example2 :

          Label: line1

          line2

 

2. My End can be different

          Example1 :

          Label: line1

          End1

or

          Example2 :

          Label: line1

          End2

 

I tried this (and it's working)

(?s)Title.*?Label:\s?\r?\n?(.*)End1  |   (?s)Title.*?Label:\s?\r?\n?(.*)End2

But my Title, Label and End are so long (more than 512 caracteres). I want to reduce the pattern.

 

Is it possible to have something like that ?

(?s)Title.*?Label:\s?\r?\n?(.*)     End1|End2

 

Thanks in advance.

Regards

0 0

Answer

SELECTED ANSWER
replied on May 28, 2018 Show version history

How about this:

(?s)Title.*?Label:\s?\r?\n?(.*?)(?=End1|End2|End3)

From here, removing spaces and extra lines should be pretty straight forward. Just make sure you have "All mathces (as multi-value token)" selected

1 0

Replies

replied on May 29, 2018

If you are just looking for the text between Label: and End do you need more than just:
(?s)Label:\s?(.*?)\nEnd

1 0
replied on May 29, 2018

Hi Kentaro, thanks for your help. I'm going to try your last solution asap.

@Andrew, the values of "End1,2,3" are different. I picked "End" for the example but in the reallity, this is differents words

Example :

End1 = "NEW DOC" and End2 = "RELEASE"

0 0
replied on May 29, 2018

@Kentaro,

 

Thank you very much! It's working!

2 0
replied on May 28, 2018

I'm not 100% sure if this works but give this a try:

(?s)Title.*?Label:\s?\r?\n?(.*)(?=End1|End2)

Hope it works!

Ken

0 0
replied on May 28, 2018 Show version history

Hi Kentaro

 

Thanks for your help. I forgot 1 difficulty, my bad.

I can have multi values  (tokens) and your solution works for only 1 but not more.

 

 

This is what I need

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.