Re: Repeating Regexp

2002-11-29 Thread Tom Allison
Paul Murphy wrote: Thanks for the answers I got for this one. There was a bit of a resounding "doh!" when I saw the "just add g" answer. I must have read about this a million times before, but those brain cells just failed to activate when I was trying to do this yesterday. Stick a "g" on t

Re: Repeating Regexp

2002-11-28 Thread Rob Dixon
Paul Another option you may like, which uses the convenient way that Perl stringifies arrays, with a space between each pair of elements. It does mean that you need a temporary array variable though: my @a = split "", "2329238023089823"; print "@a"; will output 2 3 2 9 2 3 8 0 2 3

Re: Repeating Regexp

2002-11-28 Thread Paul Murphy
Thanks for the answers I got for this one. There was a bit of a resounding "doh!" when I saw the "just add g" answer. I must have read about this a million times before, but those brain cells just failed to activate when I was trying to do this yesterday. Paul. You wrote: > >Paul Murphy

Re: Repeating Regexp

2002-11-28 Thread Paul Johnson
Paul Murphy said: > > > Hello, this is a two part question: a how to, and a how best to. > > I have a string of numbers: > > "2329238023089823" > > And I want insert a space after each number. I can see how to insert > after the first: > > s/(\d)/$1 / > > Can any one tell me how I can get the reg

Re: Repeating Regexp

2002-11-28 Thread Jean Padilla
Hello, I suggest this: #!/usr/bin/perl -w use strict; my $var1 = "23456789"; my $var2; ($var2 = $var1) =~ s/(\d)/$1 /g; # only add 'g' for global substitution print "var1 = '$var1', var2 = '$var2'\n"; Regards. Paul Murphy a écrit : > > Hello, this is a two part question: a how to, and a how