Re: Removing multiple spaces

2005-05-19 Thread John W. Krahn
Charles K. Clarkson wrote: Dale wrote: : Hi Jeff 'japhy' Pinyan, you wrote: : : : if ($line =~ /^[\s\d]+$/) { ... } : : Can I just check something here Jeff. I thought the ^ symbol was for : "not equal", so why does this work when I'm looking for digits? A circum

RE: Removing multiple spaces

2005-05-19 Thread Charles K. Clarkson
Dale wrote: : Hi Jeff 'japhy' Pinyan, you wrote: : : : if ($line =~ /^[\s\d]+$/) { ... } : : Can I just check something here Jeff. I thought the ^ symbol was for : "not equal", so why does this work when I'm looking for digits? A circumflex (^) means "not" insid

Re: Removing multiple spaces

2005-05-19 Thread Dale
Hi Jeff 'japhy' Pinyan, you wrote: if ($line =~ /^[\s\d]+$/) { ... } Can I just check something here Jeff. I thought the ^ symbol was for "not equal", so why does this work when I'm looking for digits? Cheers! -- Dale -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: Removing multiple spaces

2005-05-18 Thread John W. Krahn
Jeff 'japhy' Pinyan wrote: On May 18, Dale said: I thought that I could remove lines from the data by matching whether the first character was a letter by using the 'if' statement as : if(substr($line,0,1) eq [a-zA-Z]) ...but this doesn't work. Neither does : if($line eq [\s\d]) ...to try and fi

Re: Removing multiple spaces

2005-05-18 Thread Dale
Hi Jeff 'japhy' Pinyan, you wrote: On May 18, Dale said: Hi John W. Krahn, you wrote: If I understand you correctly then this will do what you want: $str =~ tr/ //s; Or if you want a slower method: $str =~ s/ +/ /g; This might sound a strange question, but why is the first one faster? The first one

Re: Removing multiple spaces

2005-05-18 Thread Jeff 'japhy' Pinyan
On May 18, Dale said: Hi John W. Krahn, you wrote: If I understand you correctly then this will do what you want: $str =~ tr/ //s; Or if you want a slower method: $str =~ s/ +/ /g; This might sound a strange question, but why is the first one faster? The first one is not a regex, it's merely a char

Re: Removing multiple spaces

2005-05-18 Thread Dale
Hi John W. Krahn, you wrote: Thanks for taking the time for this detailed explanation! >If I understand you correctly then this will do what you want: > >$str =~ tr/ //s; > >Or if you want a slower method: > >$str =~ s/ +/ /g; This might sound a strange question, but why is the first one faster?

Re: Removing multiple spaces

2005-05-17 Thread Peter Rabbitson
> >>$str =~ s/ / /i; > > > >is the same as: > > > >$str =~ s/\s{2,10}/ /; > > Not quite. The \s character class includes more than just the ' ' > character. > My bad :D -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Removing multiple spaces

2005-05-17 Thread Dale
Hi Peter Rabbitson, you wrote: $str =~ s/ / /i; $str =~ s/ / /i; $str =~ s// /i; $str =~ s/ / /i; $str =~ s/ / /i; $str =~ s/ / /i; $str =~ s// /i; $str =~ s/ / /i; $str =~ s/ / /i; is the same as: $str =~ s/\s{2,10}/ /; Read perldoc perlre, especially

Re: Removing multiple spaces

2005-05-17 Thread Dale
Hi David Wagner, you wrote: $str =~ s/\s+/ /g; This will take one or more white space and replace all found with one space. If you only want a space then s/ +/ /g would be what you want. white space would cover tabs and spaces. Thanks for the reply. I thought that using + would look for m

Re: Removing multiple spaces

2005-05-17 Thread John W. Krahn
Peter Rabbitson wrote: $str =~ s/ / /i; $str =~ s/ / /i; $str =~ s// /i; $str =~ s/ / /i; $str =~ s/ / /i; $str =~ s/ / /i; $str =~ s// /i; $str =~ s/ / /i; $str =~ s/ / /i; is the same as: $str =~ s/\s{2,10}/ /; Not quite. The \s character class incl

Re: Removing multiple spaces

2005-05-17 Thread John W. Krahn
Dale wrote: Hi, Hello, I'm trying to remove multiple spaces from a string but can't seemed to get it to do what I want without creating a long subroutine. I have a text file that contains various pieces of data that I want to import. However, there are gaps in between of various sizes. I want t

Re: Removing multiple spaces

2005-05-17 Thread Peter Rabbitson
> $str =~ s/ / /i; > $str =~ s/ / /i; > $str =~ s// /i; > $str =~ s/ / /i; > $str =~ s/ / /i; > $str =~ s/ / /i; > $str =~ s// /i; > $str =~ s/ / /i; > $str =~ s/ / /i; is the same as: $str =~ s/\s{2,10}/ /; Read perldoc perlre, especially the part

RE: Removing multiple spaces

2005-05-17 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Dale wrote: > Hi, > > I'm trying to remove multiple spaces from a string but can't seemed to > get it to do what I want without creating a long subroutine. > > I have a text file that contains various pieces of data that I want to > import. However, there are gaps in between of various sizes. I

Removing multiple spaces

2005-05-17 Thread Dale
Hi, I'm trying to remove multiple spaces from a string but can't seemed to get it to do what I want without creating a long subroutine. I have a text file that contains various pieces of data that I want to import. However, there are gaps in between of various sizes. I want to cut them down to