Regex substitute only outside "strings"

2009-03-30 Thread ivan budiselic
Hi, I'll post a simplified version of my problem. Basically, I want to substitute every occurrence of 'a' (the letter a, without the quotes) with 'b', but only if 'a' is not inside a string, by which I mean it is not enclosed in double quotes. So, for the line: 1234 a a "a" a I'd like to get:

Re: Regex substitute only outside "strings"

2009-03-30 Thread Andreas Bernauer
ivan budiselic wrote: > Hi, > > I'll post a simplified version of my problem. Basically, I want to > substitute every occurrence of 'a' (the letter a, without the quotes) with > 'b', but only if 'a' is not inside a string, by which I mean it is not > enclosed in double quotes. > > So, for the li

Re: Regex substitute only outside "strings"

2009-03-30 Thread Agathoklis D. Hatzimanikas
On Mon, Mar 30, at 03:00 ivan budiselic wrote: > Hi, > > I'll post a simplified version of my problem. Basically, I want to > substitute every occurrence of 'a' (the letter a, without the quotes) with > 'b', but only if 'a' is not inside a string, by which I mean it is not > enclosed in double qu

Re: Regex substitute only outside "strings"

2009-03-30 Thread ivan budiselic
On Mon, Mar 30, 2009 at 5:07 PM, Andreas Bernauer wrote: > > ivan budiselic wrote: > > Hi, > > > > I'll post a simplified version of my problem. Basically, I want to > > substitute every occurrence of 'a' (the letter a, without the quotes) > with > > 'b', but only if 'a' is not inside a string, by

Re: Regex substitute only outside "strings"

2009-03-31 Thread Andreas Bernauer
ivan budiselic wrote: >>> So, for the line: >>> >>> 1234 a a "a" a >>> >>> I'd like to get: >>> >>> 1234 b b "a" b >>> >>> The question is, is this possible and how. >>> >>> What I've tried is >>> let line = substitute(line, '\([^\"]\{-}\)a', "\\1b", "g") >> >> ...because \{-} matches also 0 times

Re: Regex substitute only outside "strings"

2009-03-31 Thread ivan budiselic
On Tue, Mar 31, 2009 at 10:13 AM, Andreas Bernauer wrote: > > ivan budiselic wrote: > >>> So, for the line: > >>> > >>> 1234 a a "a" a > >>> > >>> I'd like to get: > >>> > >>> 1234 b b "a" b > >>> > >>> The question is, is this possible and how. > >>> > >>> What I've tried is > >>> let line = subs

Re: Regex substitute only outside "strings"

2009-03-31 Thread A. S. Budden
2009/3/31 ivan budiselic : > On Tue, Mar 31, 2009 at 10:13 AM, Andreas Bernauer > wrote: >> >> ivan budiselic wrote: >> >>> So, for the line: >> >>> >> >>> 1234 a a "a" a >> >>> >> >>> I'd like to get: >> >>> >> >>> 1234 b b "a" b >> >>> >> >>> The question is, is this possible and how. >> >>> >>

Re: Regex substitute only outside "strings"

2009-03-31 Thread ivan budiselic
On Tue, Mar 31, 2009 at 4:40 PM, A. S. Budden wrote: > > 2009/3/31 ivan budiselic : > > On Tue, Mar 31, 2009 at 10:13 AM, Andreas Bernauer > > wrote: > >> > >> ivan budiselic wrote: > >> >>> So, for the line: > >> >>> > >> >>> 1234 a a "a" a > >> >>> > >> >>> I'd like to get: > >> >>> > >> >>> 1