Reply to Re: How do I get this value from a regular expression

Your name:

Reply:


Posted by Michael Fesser on 12/12/06 18:34

..oO(Moot)

>laredotornado@zipmail.com wrote:
>>
>> I'm having trouble with preg_match. I want to get the value in
>> parenthese from this pattern
>>
>> $pattern = "/ab(.*)cde/";
>> $str = "abxyzcde";
>>
>> What preg_match expression would i have to write to get the value "xyz"
>> into a string?
>>
>> I'm using php 4.4.4. Thanks, - Dave
>
>$pattern = "/(?<=ab)(.*)(?=cde)/";
>$str = "abxyzcde";
>preg_match($pattern,$str,$match);
>var_dump($match);

No need for assertions here. Just use the simple pattern from above and
you can find the result in $match[1].

Micha

[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

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