Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Return?

by Anonymous Monk
on Apr 14, 2000 at 22:49 UTC ( [id://7649]=note: print w/replies, xml ) Need Help??


in reply to Return?

Ok, thanx, I solved that problem!

Now this:
How can I see if the textbox contains ONLY spaces and nothing else?
I don't need code that checks for carriage returns and all, just for spaces.

Replies are listed 'Best First'.
RE: Re: Return?
by btrott (Parson) on Apr 14, 2000 at 22:55 UTC
    You mean just the space character? Not for any whitespace?

    To check if a string contains only space characters, use

    my $string = " "; $string = "Default" if $string =~ /^ *$/;
    This sets $string to "Default" if $string consists of 0 or more space characters, and only space characters; if $string is " a " or something such, the regular expression won't match.

    If you're looking to match strings that consist only of whitespace (no non-whitespace characters), use:

    my $string = " \t \n "; $string = "Default" if $string =~ /^\s*$/;
    \s matches whitespace, so this does the same as the last regex, but matches any whitespace (not just space characters).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://7649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found