Regex to consider 2 conditions and must include the next line that matches

regex to consider 2 conditions and must include the next line that matches.

Is there a way to adjust the existing regex to work on both sample text ?

#sample1
Home address (number and street). If you have a P.O. box, see instructions.
1124 shared passion st

output:1124 shared passion st

sample#2
Home address (number and street). If you have a P.O. box, see instructions. 267 Cats Back Road Apt. no.

output: 267 Cats Back Road

#current regex
System.Text.RegularExpressions.Regex.Match(taxFormData,"(?<= If you have a P.O. box, see instructions\.).*?(?=Apt\. no\.)").Value

As a starter help

can you please post the regex Sir , thanks.

(?<= If you have a P.O. box, see instructions\.)(.|\n)*?(st|(?=Apt\. no\.))

1 Like

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