RegExpression: Extraction to stop before a particular word

Hi

I am trying to use RegExpression to extract the text
AB1975.Jan XXX
CD2000.Jan XXX

But I end up extracting till
BA2018.May XXXXXX

How do I amend the Reg to stop the extraction before Auto? Thank you

AB1975.Jan XXX
CD2000.Jan XXX

Auto
AZ2018.Jun -XXX
BA2018.May XXXXXX

My RegExpression:
(System.Text.RegularExpressions.Regex.Match(Text1,“(?!Auto.)\n\s{3}[A-Z]{2}\d{4}.([A-Za-z]{3}|\d{1})\s{3,}(.|\n)(?<=\s{3}[A-Z]{2}\d{4}.([A-Za-z]{3}|\d{1})\s{3,}).+((?=\n.*--------------------------------------------------------------------)|(?=\n))”).Value)

Hi

Sorry, there can be any words after
AB1975.Jan XXX
CD2000.Jan XXX

So basically, I want to stop the extraction once the next line is a blank line. Thank you

I tried this, but it doesn’t work too

(System.Text.RegularExpressions.Regex.Match(Text1,“(?!Auto.)\n\s{3}[A-Z]{2}\d{4}.([A-Za-z]{3}|\d{1})\s{3,}(.|\n)(?=\n\s{4,})”).Value)

Is this your sample text?
"AB1975.Jan XXX
CD2000.Jan XXX

Auto
AZ2018.Jun -XXX
BA2018.May XXXXXX"

And you want to get the bolded text as an output?

Hi,

Thanks. Yup

Hello

Is AB1975.Jan fixed?
Is CD2000.Jan fixed also?

As in, will not change?

Hello

Try this piece of Regex:
(\D\D\d+.\D\D\D\s.\n\D\D\d+.\D\D\D\s.[\s\S\n]+)Auto

Regex 101 link

Check this below link, @Anonymous2
https://forums.asp.net/t/1316832.aspx?Using+Regular+Expressions+To+Find+Bold+Words
This may help you :slight_smile:

Hi @Anonymous2 @Steven_McKeering @Manish540

image

Just have a look to this imgs

I have just used this Regex :point_right: .+(?=Auto)
by setting Regex flags as “Global” & “Single Line”

Hope this work for your issue @Anonymous2
Bcz it works for me

Happy Automation :innocent:

Best Regards
Mr Pratik Wavhal