develooper Front page | perl.beginners | Postings from January 2002

RE: match + regexp synonyms?

Thread Previous | Thread Next
From:
Bob Showalter
Date:
January 30, 2002 14:07
Subject:
RE: match + regexp synonyms?
Message ID:
2E4528861499D41199D200A0C9B15BC031B7C4@FRISTX
> -----Original Message-----
> From: ERIC Lawson - x52010 [mailto:eric@bioeng.washington.edu]
> Sent: Wednesday, January 30, 2002 4:55 PM
> To: beginners@perl.org
> Subject: match + regexp synonyms?
> 
> 
> Why don't the match operators and regexps in the following produce the
> same results?
> 
> 	if ($editbl =~ /^\S+$/) { print AFILE "$editbl\n"; }

This checks for a string of one or more non-whitespace chars.

> 	if ($editbl !~ /^\s*$/) { print EFILE "$editbl\n"; }

This checks for a string not consisting of zero or more whitespace chars.

These are not same. Strings with both non-whitespace and whitespace chars
will return different values for the two tests.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About