On Mon, Sep 29, 2008 at 10:21 PM, loke <[EMAIL PROTECTED]> 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. That means I would need to use s/// and that is why I need to > negate the match itself. > Loke >
This is a two-step process. First, find the strings that you want to work with. Paul's suggestion is the simplest way to do that. One you have identified the strings you want, then do the substitution. You really need to resign yourself to using two different regex, one for the match, and one for the substitution. It is probably possible to construct a single substituion statement that does what you want, but it is far simpler, and almost certainly more efficient, to use two, e.g. ($string !~ m{://}) && ($string =~ s/regex/sub/}); HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!