i want to retrieve a string which falls between two specified strings multiple times in a file
i tried this, but this doesnt work
/(?m)"String 1"!.*?"String2":/;
i want every thing that falls between "String 1" and "String 2"
Please help
Assuming your input string is like this
$str='String 1GIANT FISHString 2'
this will work
($wanted)= $str =~ /String 1(.*)String 2/
$wanted
is now "GIANT FISH"
dah..multiline in a file...edit coming up
ok with multiline, assuming input of
String 1Line oneString 2
String 1GIANT FISHString 2
String 1String2
this will get all the strings
(@wanted)= $str =~ /String 1(.*)String 2/g
@wanted has three entries
('Line one','GIANT FISH','')
In the second regex, g for global finds all matches in the string
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