You are here: Re: preg_match issue « PHP Programming Language « IT news, forums, messages
Re: preg_match issue

Posted by Henri on 09/24/07 15:21

On Mon, 24 Sep 2007 15:46:16 +0200, gosha bine wrote:

> Henri wrote:
>> Hello,
>>
>> I am trying to split a string that contains parentheses; the aim here
>> is to keep the part that's before the opening parenthese:
>>
>> the string (quoted here) is "36 (72 cm)" First I want to know if the
>> string contains at least an openning parenthese; if it does, I split it
>> and extract the first token (ie "36 "). My code follows
>>
>> if (preg_match("/\(/", $sPermutationName)) {
>> $tokens = explode("\(", $sPermutationName); $sPermutationName =
>> $tokens[0];
>> }
>>
>> but that does not work. Would anyone care to enlighten me on this one?
>
> Hi Henri
>
> regular expressions would be on overkill here.
>
> strtok($a, "(")
>
> does exactly what you want - returns a portion of the string before "(".
> If there's no "(" , the whole string will be returned.

how stupid of me! the parenthese was converted to its html entity! Doh

 

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

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