Here is the input file
{1:IRVTUS30XXX}{2:I304dfaffaefa}{3:fewfa]}
:15A:
:20:1234556
:22:dsafas
dsafafaf
erwfafgr
:23:fewfd
:24:firh
:60:uncenjnjcdv
:72:uenuernfk
12345
-}
Here i want to delete some tags information from the input file. (Tags are :15A: :22: which are in between colon are called tags)
If i want to delete tag 20 i can use the below perl command:
perl -i -pe 's/:20:(.*)\r\n//g' file
But for the tags like :22: or :72: its mulitiple line tags.. How can i delete those?
Here you have the expression to select both tag no. 22 and tag no. 72 :
:(72|22):([\w\d]*(\r?\n|\r\n?)+)+
Here 'sa test of match.
Sample code for removing tag 22 (works with multi-lines or single line):
% perl -00 -pe 's/^:22:.*?(?=(?:^:\d+\w*|$))//ms' file.txt
{1:IRVTUS30XXX}{2:I304dfaffaefa}{3:fewfa]}
:15A:
:20:1234556
:23:fewfd
:24:firh
:60:uncenjnjcdv
:72:uenuernfk
12345
-}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.