754 snippets from 1514 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
PHP
(135)
JavaScript
(123)
Java
(65)
VBSCRIPT
(58)
String
(44)
CSS
(31)
CSharp
(28)
File
(28)
HTML
(27)
C
(24)
mysql
(24)
VB.NET
(24)
CPlusPlus
(23)
groovy
(23)
Random
(20)
New Snippets
Removing doubles ...
IE Explorer Proxy...
calculating md5 i...
tabless form usin...
find if array con...
Rapleaf Address B...
Javascript port o...
hash sha1
URL Regular Expre...
Email address val...
Venture Capital Jobs
New Members
Kelmi
ysg
dannymo2
chorny
wallie
Hackdemian
impomatic
cyberhitesh
omarabid
richard123
Top Members
dannyboy
sundaramkumar
mattrmiller
Pio
i_kenneth
ASmith
ctiggerf
bertheymans
SCoon
wiz1705
Home
/
Snippets
/
Simple Title case regex
/
Comments
Simple Title case regex
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
New Comment
Acronyms
Mon. Nov. 13th, 2006 8:42 AM
Mattkins
What if there is an acronym in the input?
Reply
About Acronyms
Mon. Nov. 13th, 2006 3:12 PM
RobHarrigan
Depends on the context, if the input only consists of an Acronym, then it will be lowercased. However if there is a least 1 non capitailzed character in the input, the input string will stay the same. Please view the examples in the Description.
Reply
This maybe will work
Thu. Nov. 16th, 2006 6:24 PM
aelander
sub capsAcronym {
my $myString = $_[0];
if ($myString !~ /[a-z]/) {
$myString = lc $myString;
$myString =~ s/(.)/eval uc $1/e;
$myString =~ s/ (\w)/' '.eval uc $1/eg;
}
return $myString;
}
Reply
New Comment
my $myString = $_[0];
if ($myString !~ /[a-z]/) {
$myString = lc $myString;
$myString =~ s/(.)/eval uc $1/e;
$myString =~ s/ (\w)/' '.eval uc $1/eg;
}
return $myString;
}