Welcome to WebmasterWorld Guest from 54.234.244.30

Forum Moderators: open

Message Too Old, No Replies

regexp: convert upper case to lower case

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

Preferred Member

10+ Year Member

joined:May 4, 2004
posts: 394
votes: 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!

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

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 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

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

Full Member

5+ Year Member

joined:Mar 4, 2008
posts: 210
votes: 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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members