I want to match words which have special characters in it...
Posted: Wed Feb 01, 2006 8:45 am
I expect to match
rough**ly
tha&&t
docum//ents
but this returns...
rough**ly
tha&&t
docum//ents
Code: Select all
<?php
$input = <<<EOD
Character data is rough**ly all the (non-markup) contents2343 of XML docum//ents, including white234324space
between tags. Note tha&&t the XML par2756724ser does not add or remove any (whitespace), it is up to the33333
application (you) to decide whether whitespace5555 is significant.
EOD;
echo preg_match_all("/\b\w+(\W+)\w+\b/mi", $input, $matches)."<br />";
print_r($matches);
?>Code: Select all
Array
(
[0] => Array
(
[0] => Character data
[1] => is rough
[2] => ly all
[3] => the (non
[4] => markup) contents2343
[5] => of XML
[6] => docum//ents
[7] => including white234324space
[8] => between tags
[9] => Note tha
[10] => t the
[11] => XML par2756724ser
[12] => does not
[13] => add or
[14] => remove any
[15] => whitespace), it
[16] => is up
[17] => to the33333
[18] => application (you
[19] => to decide
[20] => whether whitespace5555
[21] => is significant
)
[1] => Array
(
[0] =>
[1] =>
[2] =>
[3] => (
[4] => )
[5] =>
[6] => //
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
[12] =>
[13] =>
[14] =>
[15] => ),
[16] =>
[17] =>
[18] => (
[19] =>
[20] =>
[21] =>
)