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/
[Back to original message]
|