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

Posted by Jψrn Dahl-Stamnes on 12/16/73 11:58

malatestapunk wrote:

>
> JΓΈrn Dahl-Stamnes wrote:
>> I try to use preg_match to find out if a string begins with either
>> "http", "/somethime" or "../something". In my php script I have the
>> following line:
>>
>> if (0 == preg_match("/^(http.+)|(\/[a-z].+/)|(\.\.[a-z]+)/i",$string)
>>
>> But I get a:
>>
>> Warning: Unknown modifier ')' in myscript.php at line nn
>>
>> What's wrong with the pattern?
>>
>> --
>> JΓΈrn Dahl-Stamnes
>> http://www.dahl-stamnes.net/dahls/
>
> If that is your exact line of code, then you missed escaping a slash
> (trailing slash in second matching group, after the plus sign):
>
> ... |(\/[a-z].+/)| ...

Yes, I found that extra / in the expression some time after I posted my
message (typical :-)

Thanks.

--
JΓΈrn Dahl-Stamnes
http://www.dahl-stamnes.net/dahls/

 

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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация