in reply to Swap between first found match

If you just want to change the first instance on a given line, then it is just a s/// command but don't use the g modifier.

s/"[^"]*"/"that"/;

Replies are listed 'Best First'.
Re: Re: Swap between first found match
by Roger (Parson) on Mar 04, 2004 at 03:25 UTC
    Use non-greedy match:  .*?
    s/".*?"/"that"/;

      What's wrong with a negated character class? [^"]

        Nothing wrong, just 2 more characters to type.