iwato Posted January 27, 2011 Share Posted January 27, 2011 The PROBLEM: Consider the following concatenated string and $tag variable'(.+</'.$tag.'(>|\s[^>]*>)|)'The $tag variable is a string containing the name of an HTML tag. The concatenated string is later combined with other strings (not shown) to form a regex pattern for use with a PCRE function.INTERPRETATION: In order to understand the concatenated string above I replace the value of the $tag variable with 'tag' and remove the internal single quote delimiters, as well as the concatenation operators. In so doing I obtain the following three alternative patterns: '.+</tag>' '.+</tag(\s[^>]*>)' '()' Although I can easily make sense of the first and third patterns, I am having trouble making sense of the second pattern. I have never seen an HTML closing tag with white space and other characters between the </tag characters and the > character.Have I misinterpreted the string '(.+</'.$tag.'(>|\s[^>]*>)|)' ?If not, can you give an example of what the subpattern (\s[^>]*>) might be anticipating?Roddy Link to comment Share on other sites More sharing options...
justsomeguy Posted January 27, 2011 Share Posted January 27, 2011 That's right, it's anticipating whitespace or other characters after the name in the closing tag. I don't know why they decided to account for that, but that's what it's looking for. Link to comment Share on other sites More sharing options...
jeffman Posted January 27, 2011 Share Posted January 27, 2011 Murphy's law. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.