Yip Weng Tak
Yip Weng Tak

Reputation: 15

Regular expression multiline stop at a pattern

I have this text

Owner's Name : John doe
State : New York
Country : US
Address : address line 1
address line 2
46000
Tel. No. (Off) : xxxx

I would like to use regular expression to capture

Address : address line 1
address line 2
46000

This stops at the Tel line...(doesn't capture).

Been trying to use lookahead but to no avail.

Upvotes: 1

Views: 91

Answers (1)

anubhava
anubhava

Reputation: 785058

You can use this regex:

Address *: *([\s\S]*?)(?=Tel\. No\.)

RegEx Demo

Upvotes: 3

Related Questions