You are here: Re: Question on PHP regular expressions « PHP Programming Language « IT news, forums, messages
Re: Question on PHP regular expressions

Posted by Carl on 11/08/07 19:17

sberry <sean@buildingonline.com> writes:

> In PHP I have many more options for functions that do regular
> expression than I did in Perl. My question is what is the best one to
> use for doing the following:
>
> Give the following:
> {Somestring.somestring.somestring} blah blah {somestring} value here
> not used {more.text.here}
>
> I want an array like the following:
> [0] => Somestring.somestring.somestring
> [1] => somestring
> [2] => more.text.here
>
> So basically I just want to capture the contents (alpha-numeric +
> periods) inside of curly braces.
>
> Thanks for any help.

This should get you started:

$string = "{Somestring.somestring.somestring} blah blah
{somestring} value here not used {more.text.here}";
$pattern = '/\{.+?\}/';
preg_match_all($pattern, $string, $matches);
print_r($matches);

Hope that helps,

 

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

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