loke wrote:
On Sep 29, 11:03 am, [EMAIL PROTECTED] (Paul Lalli) wrote:
On Sep 28, 3:18 pm, [EMAIL PROTECTED] (Loke) wrote:

Hi. I am trying to filter strings which do not have :// in them, I am
able to find strings with :// but I want to do the exact opposite.
regex to match :  /(.*:\/\/.*)/i
I tried /(.*(?!:\/\/).*)/i but it does not work.
if ($string !~ m{://}) { ... }

Paul Lalli
Paul:
Thanks for the help, but I think I have not put my problem correctly.
I want to match and replace only strings which do not have :// in
them.

/:\/\// or s/something/something else/;

That means I would need to use s/// and that is why I need to
negate the match itself.

Say you have the string 'one://two', your example /(.*(?!:\/\/).*)/ won't work because '(?!://)' *will* match 'one', 'ne:', 'e:/', '//t', '/tw' or 'two'. You need to use a consistent unique pattern that will anchor the '(?!://)' pattern.




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to