Re: deleting white spaces

2001-11-28 Thread John W. Krahn
Jeff 'Japhy' Pinyan wrote: > > I suggest a negative look-behind and a negative look-ahead: > > $string =~ s/(? > But that might take too long, since it's probably not optimized the way it > should be. So I'd probably go with: > > $string =~ s/(\s+)/length($1) == 1 and $1/eg;

Re: deleting white spaces

2001-11-28 Thread Michael Fowler
On Wed, Nov 28, 2001 at 04:03:46PM -0500, Jeff 'japhy' Pinyan wrote: > On Nov 28, Michael Fowler said: > >Given a version of Perl 5.6 or greater, then the substitution could become: > > > >s/(? > That works in 5.005 too. Ah, so it does. Thank you for the correction. Michael -- Administrat

Re: deleting white spaces

2001-11-28 Thread Jeff 'japhy' Pinyan
On Nov 28, Michael Fowler said: >On Wed, Nov 28, 2001 at 11:56:30AM -0800, Ahmed Moustafa Ibrahim Ahmed wrote: >> You don't you need the line beginning and line termination in >> s/(^|[^ ]) ([^ ]|$)/$1$2/g; > >Given a version of Perl 5.6 or greater, then the substitution could become: > >s/(?

Re: deleting white spaces

2001-11-28 Thread Michael Fowler
On Wed, Nov 28, 2001 at 11:56:30AM -0800, Ahmed Moustafa Ibrahim Ahmed wrote: > You don't you need the line beginning and line termination in > s/(^|[^ ]) ([^ ]|$)/$1$2/g; It depends on what is desired in the two edge cases of " foobar" and "foobar ", and what version of Perl is being used. I wa

Re: deleting white spaces

2001-11-28 Thread Jeff 'japhy' Pinyan
On Nov 28, Ahmed Moustafa Ibrahim Ahmed said: >You don't you need the line beginning and line termination in >s/(^|[^ ]) ([^ ]|$)/$1$2/g; > >Would >s/([^ ]) ([^ ])/$1$2/g >be simpler? But it doesn't work in all cases: $_ = "a "; s/([^ ]) ([^ ])/$1$2/g; print; # "a " But the (^|[^x]) app

Re: deleting white spaces

2001-11-28 Thread Jeff 'japhy' Pinyan
On Nov 28, Michael Fowler said: >$_ = "I want to delete all this spaces, but this"; >s/(^|[^ ]) ([^ ]|$)/$1$2/g; > >It seems there should be a simpler way, perhaps without the $1 $2 >replacement, but that's the best I came up with. My look-behind/ahead approach does, but I d

Re: deleting white spaces

2001-11-28 Thread Ahmed Moustafa Ibrahim Ahmed
2001 11:40 AM Subject: Re: deleting white spaces On Wed, Nov 28, 2001 at 01:06:19PM -0500, Pedro A Reche Gallardo wrote: > Hi all, I would like to delete all single white spaces from a string > without deleting concatenated white spaces. An example: > $string= "I want to delete a

Re: deleting white spaces

2001-11-28 Thread Michael Fowler
On Wed, Nov 28, 2001 at 01:25:51PM -0500, [EMAIL PROTECTED] wrote: > $string = "I want to delete all this spaces, but this"; > $string =~ s/\s{1}(?=\w)//g; > print $string; Almost, but it doesn't match his description. Consider a few edge cases: "foo bar" is chang

Re: deleting white spaces

2001-11-28 Thread Michael Fowler
On Wed, Nov 28, 2001 at 01:06:19PM -0500, Pedro A Reche Gallardo wrote: > Hi all, I would like to delete all single white spaces from a string > without deleting concatenated white spaces. An example: > $string= "I want to delete all this spaces, but this" > > The result would be: >

RE: deleting white spaces

2001-11-28 Thread RArul
November 28, 2001 1:39 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: deleting white spaces > > > Rex, > > Would you explain your regexp, please? Also, what do you > think about this: > $string =~ s/([^\s])\s([^\s])/$1$2/g; &g

RE: deleting white spaces

2001-11-28 Thread Ahmed Moustafa Ibrahim Ahmed
Rex, Would you explain your regexp, please? Also, what do you think about this: $string =~ s/([^\s])\s([^\s])/$1$2/g; Thanks, Ahmed On Wed, 28 Nov 2001 [EMAIL PROTECTED] wrote: > Let me give it a shot...How about this? > --Rex > > $string = "I want to delete all this spaces, but

Re: deleting white spaces

2001-11-28 Thread Jeff 'japhy' Pinyan
On Nov 28, Pedro A Reche Gallardo said: >Hi all, I would like to delete all single white spaces from a string >without deleting concatenated white spaces. An example: >$string= "I want to delete all this spaces, but this" > >The result would be: > >$string = "Iwanttodeleteallthisspa

RE: deleting white spaces

2001-11-28 Thread Jenda Krynicky
> Let me give it a shot...How about this? > --Rex > > $string = "I want to delete all this spaces, but this"; > $string =~ s/\s{1}(?=\w)//g; print $string; 1) I bleive you meant \S and not \w $string =~ s/\s{1}(?=\S)//g; print $string; 2) It doesn't work correc

RE: deleting white spaces

2001-11-28 Thread RArul
Let me give it a shot...How about this? --Rex $string = "I want to delete all this spaces, but this"; $string =~ s/\s{1}(?=\w)//g; print $string; > -Original Message- > From: Pedro A Reche Gallardo [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, November 28, 2001 1:06 PM > T