I want to get the mid string between SHIP TO: and Account:.
Example Input
SHIP TO: Abc Supply, Inc
123 S. Ramesh
Centralia IL 12345
Account: 234
Expected Output
Abc Supply, Inc
123 S. Ramesh
Centralia IL 12345
I want to get the mid string between SHIP TO: and Account:.
SHIP TO: Abc Supply, Inc
123 S. Ramesh
Centralia IL 12345
Account: 234
Abc Supply, Inc
123 S. Ramesh
Centralia IL 12345
This question was already asked and answered: Regex match everything between two string, spaning multiline
Use the regex SHIP TO:(.*)Account: with multi-line flag
SHIP TO: starts the matching. If not given in input, it wont match!(.*) is the first capture-group (inside parentheses) matching everything .* ... untilAccount: ends the matching. So if no Account: is present then it wont match!(?m)) can be supplied by the regex-engine / programming-language you useIt does match your given example:
SHIP TO: Abc Supply, Inc
123 S. Ramesh
Centralia IL 12345
Account: 234
and extract expected output as group #1:
Abc Supply, Inc
123 S. Ramesh
Centralia IL 12345
with any character (space) after SHIP TO: and any character (newline) before Account:
See demo on RegexPlanet