Regular expression (Regex)

I need a regex expression for the following text: I need the bold text

Notification number


Name

Address

Country


Notification

I have problems with my house.


Date

Department

1 Like

So you need the string before ‘Date’ and after 'Notification?

If so you can use a combination of look ahead and lookbehind as below:
(?<=Notification)\s+(.*)\s+(?=Date)

4 Likes

Thnx bro :slight_smile:

1 Like

Another question @TimK

If the notification is longer than a sentence? for example:

Notification

what if the report is longer than a line?
this is just an example
I am curious about this
it can therefore vary.

History

Date

Department

1 Like

@Nalube So you want to change the way the regex looks at the string due to the multiple lines.

Your key identifier word has also changed from Date to History.

(?<=Notification)((?:.|\n)*)(?=\nHistory)

Please do look at Regex Learning to enhance your understanding of Regex :ok_hand:

3 Likes

@Nalube

Below pattern will work for both scenario

Notification\s\n+\K(?:.|\n\S)*

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.