RegExp parsing after preg_quote
After doing some preg_quote I want to parse a string but this ends in
disaster. Via online regexp evaluators everything works fine but local are
some issues.
$subject = '\<\:foo\|\.\*\>';
$pattern = '@\\<\\:(\w+)\\|(.*?)\\>@is';
$result = preg_match_all($pattern, $subject, $subpattern);
The source will be something like this: http://regexr.com?35s7t
\<\:foo\|\.\*\> \<\:bar\|\.\*\> \<\#baz\>
And I want to fetch everything like this (for example):
<:(foo)|(.*)> <:(bar)|(.*)> <#(baz)>
So it would be great if the matches look like this:
Array (
[0] => Array ( [0] => \<\:foo\|\.\*\>)
[1] => Array ( [0] => foo )
[2] => Array ( [0] => \.\* )
)
But actually it's something total different:
array(3) {
[0]=>
array(1) {
[0]=>
string(15) "\<\:foo\|\.\*\>"
}
[1]=>
array(1) {
[0]=>
string(0) ""
}
[2]=>
array(1) {
[0]=>
string(13) "\<\:foo\|\.\*"
}
}
Why is it so different from the online one? And how to get the information
correct?
No comments:
Post a Comment