Re: strip first space

2002-03-01 Thread Tanton Gibbs
my @arr = ( This has a leading space, This does not ); foreach my $string (@arr ) { $string =~ s/^\s//; print $string, \n; } prints: This has a leading space This does not The regular expression s/^\s//; means s/ # substitute ^ # at the beginning of the string \s

Re: strip first space

2002-03-01 Thread Elaine -HFB- Ashton
Tanton Gibbs [[EMAIL PROTECTED]] quoth: * *The regular expression *s/^\s//; s/^\s+//g; would be even better as it would remove all whitspace at the beginning of a line and it would replace all matches to the pattern instead of just the first it finds. e. -- To unsubscribe, e-mail: [EMAIL

Re: strip first space

2002-03-01 Thread William.Ampeh
$string =~ s/^\s+//; Removes leading whitespaces $string =~ s/^\s+//g; /g (GLOBALLY) is redundant in the case of leading whitespages See PERL Cookbook page 30 for the answer to your question. __ William Ampeh (x3939) Federal Reserve Board

RE: strip first space

2002-03-01 Thread Jason Larson
If I have a string and the first character is a space, may not always be a space. Example: John Tommy Beth John and Beth have a space, Tommy does not. How do I strip that. I do not want to use the global command because a want the space between First and

Re: strip first space

2002-03-01 Thread Elaine -HFB- Ashton
[EMAIL PROTECTED] [[EMAIL PROTECTED]] quoth: * *$string =~ s/^\s+//; Removes leading whitespaces * *$string =~ s/^\s+//g; /g (GLOBALLY) is redundant in the *case of leading whitespages For a beginner, it's a not a critical detail. e. -- To unsubscribe,