homepage Welcome to WebmasterWorld Guest from 50.19.169.37
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
regexp: convert upper case to lower case
stef25




msg:3602231
 6:23 pm on Mar 16, 2008 (gmt 0)

could anyone tell me how to do this, in the format of replace(x,x)? i have a regexp cheat sheet that has the posix notations as [:upper:] and [:lower:] but firebug throws an error when i try to use this.

id imagine this is quite simple, just cant track it down. thanks!

 

DrDoc




msg:3602266
 7:04 pm on Mar 16, 2008 (gmt 0)

You have two ways of approaching this:

1) In JavaScript: string = string.toUpperCase();
2) Use CSS to display it in all caps regardless of string casing

MarkFilipak




msg:3602398
 11:40 pm on Mar 16, 2008 (gmt 0)

FYI: Javascript uses perl-style regular expressions, not posix.

replace(/x/ig, 'X') will find all occurrences of 'x' or 'X' and replace them with 'X', and
replace(/x/ig, 'x') will find all occurrences of 'x' or 'X' and replace them with 'x',
but the toUpperCase() and toLowerCase() methods are the preferred way to shift case with an arbitrary string.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved