Monks,
I am a bit confused with multi line matching, how can I get the value of property name "Text" to match since it spans across multiple lines?
Thanks!
#!/usr/bin/perl use strict; use warnings; while(<DATA>) { if (/<cdset id/.../<\/cdset/) { if ($_ =~ /<property name="(.*)"\s+value="(.*)"\/\>/ms) { print "$1 -> $2\n"; } elsif ($_ =~ m/<property name="(.+)"\s+value=""\/\>/) { # if no value print "$1 -> \"\"\n"; } } } __DATA__ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <set name="01" id="test" catId="81679" > <cdsets> <cdset id="cdset" name="CD Compilation"> <property name="Own" value=""/> <property name="Type" value="Record"/> <property name="Text" value="Sample text more sample text more more same text]."/> <property name="Unique" value="yes"/> </cdset> </cdsets> </set> Output: Own -> Type -> Record Unique -> yes
In reply to Perl Regex Multiline Matching by yoda54
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |