Today I had to find a way to proper case a string, except anything that is in parenthesis. That sounds like a mouthful, so to clarify, I wanted to turn “JAVASCRIPT ROCKS (JS)” into “Javascript Rocks (JS)”, so I created a regular expression to do this task in an Adobe LiveCycle form.
1 2 3 4 |
this.rawValue = this.rawValue.replace(/(?!\w*\))(\w\S*)/g, function(txt){ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();} ); |
I learned that […]