Regex everything between 9 digit numbers

Hey there,

I have a problem with using Regex on a certain input text.
I want to extract everything between the 9 digit numbers.

Input Text
111111111 1 Street Streetold 11 Streetnew 11
PC 33333 32321
City Test City Testvillage
222222222 1 Street Teststr 4 Testhill 7
333333333 1 Street Street Test 136 Testing Street 18
Page 1 of 5

Expectations
For first case:
1 Street Streetold 11 Streetnew 11
PC 33333 32321
City Test City Testvillage

Second:
1 Street Teststr 4 Testhill 7

Third:
1 Street Street Test 136 Testing Street 18

I tried (?<=\d{9}).*\n(?=\d{9}|Page) but this doesn’t extract first case…

Maybe you can help :slight_smile:

@JenJen
(?<=\d{9}).*(?:(?=\d{9})|(?=\nPage))
Hope it helps

Hi @JenJen

Could you provide the input and required output so that it’s easy to write regex.

Regards,

Hi @JenJen
(?<=\d{9}\s)(.*?)(?=\s\d{9}|Page)

I provided all information in my initial post :slight_smile:

Hi @JenJen

Try this

(?<=\d{9}\s)(.*)

I hope it helps!!

In the first case it doesn’t extract the second and third line with PC and City… that should be included in first match as well.

Hi @JenJen ,

Could you check with the below Regex Expression :

(?<=\d{9})[\s\S]+?(?=\d{9}|Page)

Here, An assumption is also made that the Page keyword will always be present after the last address data.

Let us know if it is not the case, we can identify a separate limiter.

2 Likes

It works :smiley: Thank you very much

1 Like

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