What is the meaning of this statement

May 18, 2010 at 03:26:57
Specs: Debian Linux x86_64
if($filterResp =~ /<MATCH(.*?)>(.*)<\/MATCH>/si)

What is the meaning of that above statement?


See More: What is the meaning of this statement

Report •

#1
May 21, 2010 at 18:21:14
What language is this "if" statement from? Perl?

$filterResp =~ /
variable $filterResp matches the regular expression...

<MATCH
characters "<MATCH" followed by...

(.*?)
0 or more "any" characters (non-greedy match) followed by...

>
a ">" followed by...

(.*)
0 or more "any" characters followed by...

<
a "<" followed by...

\/
a literal / (escaped so as to NOT end the pattern) followed by ...

MATCH>
"MATCH>"...

/si
end of pattern. s = ". can match a newline", i = "ignore case"...

)
end of if ( ).

So, you're looking to see if $filterResp contains <MATCH anything> anything </MATCH>, where this can spread across multiple lines, and "match" or "Match" etc. are also recognized. There is a possibility that the .* between the tags, being "greedy", will swallow the </MATCH> following it. If that happens, you might have to use (.*?) (non-greedy).


Report •
Related Solutions


Ask Question