regex not working as expected
Posted: Sun May 17, 2009 1:19 am
Hi All,
I have an input string that is multi-line (i.e. I have slurped in an entire file) -- I am trying to match the data within some some xml-like tags , for example:
$input =~ /<header>(.+)<\/header>/
...so I am using perl to do the above expression, expecting that everything between the "header" tags will be returned in $1...my understanding according to perl is that by default this should work because we are not in multiline mode...however, the above does not work....but when I remove all the carriage returns from the input string, it works (which suggests it is in multi-line mode by default)...what am I doing wrong?
thanks in advance!
I have an input string that is multi-line (i.e. I have slurped in an entire file) -- I am trying to match the data within some some xml-like tags , for example:
$input =~ /<header>(.+)<\/header>/
...so I am using perl to do the above expression, expecting that everything between the "header" tags will be returned in $1...my understanding according to perl is that by default this should work because we are not in multiline mode...however, the above does not work....but when I remove all the carriage returns from the input string, it works (which suggests it is in multi-line mode by default)...what am I doing wrong?
thanks in advance!