|
Posted by Dimitrios Mexis on 10/13/64 11:36
Janwillem Borleffs wrote:
> m6s wrote:
>
>>I passed this to the pgrep_match :
>>$arrayTR = "<td>The value in cell 1</td><td>and cell 2</td>";
>>if ( preg_match( '<(\w+)*?>(.*?)</\1>', $arrayTR, $m ) ) {
>> print "Finding the cells...".$m[1]."\n";
>>}
>>and prints...
>>Warning: preg_match(): Unknown modifier '(' in C:\Documents and
>>Settings\m6s\My Documents\projects\php\test.php on line 7
>>
>>>Exit code: 0
>>
>>which mean?! :-(
>>
>
>
> Read the man page: http://www.php.net/manual/en/ref.pcre.php; the problem is
> that regular expression patterns should be enclosed with delimeters, e.g.:
>
> |<pattern>|
>
> where the pipes are the delimeters applied to indicate the pattern's start
> and end.
>
> If you would change your code into the following:
>
> $arrayTR = "<td>The value in cell 1</td><td>and cell 2</td>";
> if (preg_match('|<(\w+)*?>(.*?)</\1>|', $arrayTR, $m)) {
> print "Finding the cells...".$m[1]."\n";
> }
>
> You will get "Finding the cells...td". When you examin $m with the print_r()
> function, you will notice that the string you are expecting will be in the
> third nested array within $m ($m[2]).
>
> If you want to match all occurances, use preg_match_all (see
> http://www.php.net/preg_match_all for more info).
>
>
> JW
>
>
Yes indeed, before I got to read this reference, I came to this
conclusion after matching the previous snippet with the current, and saw
that those chars were missing... :-)
Thank you!
Navigation:
[Reply to this message]
|