ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Stevens <insomniacpeng...@googlemail.com>
Subject Re: Advanced Regexp Question
Date Sun, 08 Jan 2012 03:42:34 GMT
On 6 Jan 2012 21:12, <Greg.Zoller@aviall.com> wrote:
> Say I have a string in a file like this:
>
>        require(["a","foo/b","foo/c"], function(){...})
>
> What I want to do is replace all the "foo" with "bar" so the final product
> looks like this:
>
>        require(["a","bar/b","bar/c"], function(){...})
>
> With replaceregexp the best I've been able to get was below using regexp
> like "require\(\s*\[(.*)foo/([^\]]*)\]"
>
>        require(["a","foo/b","bar/c"], function(){...})
>
> (I can't just do a global replace on "foo" because I only want to do the
> replacement in this "require" context.)
>
> Any ideas?

Run your regexp over the file twice? Second pass will catch the foo that
was left over the first time.

Andy.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message