I am trying to select everything after CORP ACT OPTION NO
up until 2 new lines and carriage returns (up to safekeeping account in example)
My reg expression atm to extract the info (all of it after CORP ACT OPTION) is
CORP ACT OPTION NO\.([\s\S]*)
Sample dara:
CORP ACT REFERENCE : 007XS0212069115
SENDER'S REFERENCE : 1212070800330001
FUNCTION OF MESSAGE : NEW MESSAGE
CORP ACT EVENT : INTEREST PAYMENT
PLACE OF SAFEKEEPING : US
ISIN : XS0212069115
ISIN/DESCRIPTION : KFW 4.750 071212 GBP
METHOD OF INTEREST COMPUTATION : A006
EX-DATE : 20121207
RECORD DATE : 20121206
CORP ACT OPTION NO. : 001
CORPORATE ACTION OPTION CODE : CASH
CURRENCY OPTION : GBP
RESULTING AMT : GBP617,5
PAYMENT DATE : 20121207
EXCHANGE RATE : GBP/GBP/1,
INTEREST RATE : 4,75
SAFEKEEPING ACCOUNT : 000000000000
CONFIRMED BALANCE : FAMT/13000,
CREDIT/DEBIT IND : CREDIT
How can I select up until the line break above SAFEKEEPING ACCOUNT?
Many thanks.
/.*\s*:\s*.*/g
should work fine. Without m
the match isn't going to match more than one line.
Explanation of regex:
.*
match as much as possible until followed by:
\s*:
*any amount of spaces (0 or more) followed by a litteral :
character\s*
any amount of spaces (0 or more)
.*
match as much as possible until the linebreak
Regex101 Demo
You can also use capture groups and check every key with every value:
/(.*)\s*:\s*(.*)/g
Regex 101 Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With