You are here: Re: How do I get this value from a regular expression « PHP Programming Language « IT news, forums, messages
Re: How do I get this value from a regular expression

Posted by Moot on 12/12/06 18:12

laredotornado@zipmail.com wrote:
> Hi,
>
> 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);

For documentation, look under the "Assertions" heading here:
http://us3.php.net/manual/en/reference.pcre.pattern.syntax.php

- Moot

 

Navigation:

[Reply to this 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

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