Reply to Re: Split

Your name:

Reply:


Posted by Janwillem Borleffs on 10/13/27 11:36

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация