[Tutor] problem in replacing regex
Kent Johnson
kent37 at tds.net
Wed Apr 8 12:34:49 CEST 2009
> Kumar <hihiren1 at gmail.com> s'exprima ainsi:
>
>> Hi Danis,
>>
>> Just to be more specific that I can add [^/] in my expression which will
>> successfully work for url (i.e. http://sdfs/123-34) but it will also work
>> for non url (i.e. /123-34 ) so u am just trying it to make it specific for
>> url only
>> I have already tried [^(http).*/] but that also failed and it didn't work on
>> /123-34
The [^] don't do what you think they do.
In a regex, [abc] means, match a single character that is either a, b,
or c. [^abc] means match a single character that is not a, not b and
not c. It does *not* mean to match a three-letter string that is not
abc, or anything like that.
I think you are trying to write a negative look-behind, something like
(?<!http//:) but it's hard to be sure without seeing your code.
Did you try Denis' suggestion of a single regex to match both patterns?
Kent
PS Please use Reply All to reply to the list.
More information about the Tutor
mailing list