Re: Overlapping substitution

2007-10-18 Thread Dr.Ruud
Kevin Viel schreef: > [.] matches . > [?] matches ? > [*] matches * > > Can they be combined? > > [.*] Yes, and that looks better than (?:\.|\*), but could actually be somewhat slower. (not slower in Perl 5.10 though) -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL

Re: Overlapping substitution

2007-10-18 Thread Chas. Owens
On 10/18/07, Kevin Viel <[EMAIL PROTECTED]> wrote: snip > Are these character classes that have single elements? In other words: > > [.] matches . > [?] matches ? > [*] matches * > > Can they be combined? > > [.*] snip Yes, that last example is a character class that will match '.' or '*'. -- T

RE: Overlapping substitution

2007-10-18 Thread Kevin Viel
> -Original Message- > From: Dr.Ruud [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 18, 2007 3:03 AM > To: beginners@perl.org > Subject: Re: Overlapping substitution > I started using "[.]" and "[?]" and "[*]" etc., in procmail recipes

Re: Overlapping substitution

2007-10-18 Thread Dr.Ruud
"Chas. Owens" schreef: > The brackets are being used because some people find [.] easier to > read than \.. Yes, I do that for expressions that are not in a loop that runs a zillion times, this because in Perl up to 5.8.8 the "[.]" is a bit less fast than "\.". In Perl 5.10 this difference is gon

Re: Overlapping substitution

2007-10-17 Thread Chas. Owens
On 10/16/07, Kevin Viel <[EMAIL PROTECTED]> wrote: snip > > If the first field can be just a dot too, consider this: > > > > s/ (\A|,) [.] (?=,|\z) /$1/xg > ^ ^ ^^ > > (if you chomp first :) > > Thank you kindly for your response. Are the spaces, which I highlighted > with c

RE: Overlapping substitution

2007-10-17 Thread Kevin Viel
> -Original Message- > From: Dr.Ruud [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 16, 2007 3:57 PM > To: beginners@perl.org > Subject: Re: Overlapping substitution > > > If the first field can be just a dot too, consider this: > >

Re: Overlapping substitution

2007-10-16 Thread Dr.Ruud
Kevin Viel schreef: > I have to change the a CSV file, which represents numeric missing > data with a period (.). For instance: > > One,.,.,. > > Should be: > > One,,, If the first field can be just a dot too, consider this: s/ (\A|,) [.] (?=,|\z) /$1/xg (if you chomp first :) -- Affi

Re: Overlapping substitution

2007-10-16 Thread yaron
Hi, I think that you are looking for a "zero-width positive lookahead assertion" i.e. (?=...) So a solution for problem might be: my $line = ",.,.,."; $line =~ s/,\.(?=,|$)/,/g; TTFN Yaron Kahanovitch - Original Message - From: "Kevin Viel" <[EMAIL PROTECTED]> To: beginners@perl.or

RE: Overlapping substitution

2007-10-16 Thread Kevin Viel
> -Original Message- > From: Jenda Krynicky [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 16, 2007 2:24 AM > To: beginners@perl.org > Subject: Re: Overlapping substitution > $s = 'One,.,.,.'; > $s =~ s/,\.(?=,|$)/,/g; > print $s; Diky moc. F

Re: Overlapping substitution

2007-10-16 Thread Jenda Krynicky
On 15 Oct 2007 at 14:19, Kevin Viel wrote: > I have to change the a CSV file, which represents numeric missing data > with a period (.). For instance: > > One,.,.,. > > Should be: > > One,,, > > I have written: > > > $_ =~ s/,\.,/,,/g ; > > > However, I have a requirement to substitute ov