Along the same lines, if you just want to know if it is capitalized, you
can say $all_caps = $str eq uc $str;

Good Luck!
Tanton

-----Original Message-----
From: Christopher Solomon
To: Charles Lu
Cc: [EMAIL PROTECTED]
Sent: 8/25/2001 7:05 PM
Subject: Re: alternative to regex when checking for captitalization

On Sat, 25 Aug 2001, Charles Lu wrote:

> Does anyone know if there is a built in function that allows you to
check to 
> see if all the characters in a string is capitalized or not?  In other
words 
> is there a way to check to see if a string is capitalized without
using  
> regular expression?  Thanks alot
> 

Do you need to know if it's capitalized, or do you just want to make it
capitalized if it isn't? 

If you just want to make sure text is capitalized, you can use the
uc() function, or use \U and \E to bracket text.

eg. 
$foo = "bar";
uc($foo);
# $foo is now: "BAR"

or

$foo = "bar";
$uc_foo = "\U$foo\E";
# $uc_foo is now: "BAR";

in the latter example, \U starts the capitalization, and \E ends it.

Chris


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to