I am struggling to find a method to extract the first two lines of an address using a regular expression, where it doesn't include the word "Account".
If we take this address:
Company Name
Some Road
Some Town
I can use the regular expression (?:.*\s*){2}
to return
Company Name Some Road
Which is great.
However, if there is an extra line at the top, making the address become:
Accounts Payable
Company Name
Some Road
Some Town
Then it no longer picks up those two lines that I want.
I have tried the method here: Regular expression to match a line that doesn't contain a word? without success, and have also tried combinations of using things like (?!Account.*)(?:.*\s*){3}
, but am having little success.
The Microsoft website https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference has masses of characters etc to use, but I haven't managed to get a combination working yet.
The closest I've got was using [^Account.*](?:.*\s*){3}
which returns
s Payable Company Name Some Road
I just can't get it to remove the rest of that line! Any help would be appreciated. Thanks.