I wanted to Capitalize all first letters of a name (whether it's a proper name or company name etc). I was thinking instead of writing a function I could do it with a regexp but I am not that 'good' with regexp and was looking for advice. Should I use regexp or just code a function? If I use regexp could someone provide me with the details?
If I use regexp could someone provide me with the details?
Regex is not a simple library -- it is argubly its own language. So... if you want to use regex, you need to just dive in and learn it. (Basically, get a book and learn it. It won't be wasted, as once you get the regex hammer into your toolbox, everything will start looking like a nail... )
Once you get started... take a look at the find(), appendReplacement(), and appendTail() methods. Basically, you need the regex to look for the beginning of the word that starts with a lower case character, and then convert them to upper case.
The standard regex replaceFirst() and replaceAll() methods don't support the conversion to uppercase (or any type of conversion), so you'll need to use the appendXXX() methods.