For eg: if the string has a camelcase in it - like ‘viceVersa’, the result expected is ‘vice-Versa’. Similarly if a string has a dash in it, like ‘dot-net’, the result expected is ‘dotNet’. Let’s see the piece of code to make this possible:
Let’s see some important bits of the code shown above.
The /\W+/ pattern matches one or more of any of A-Z, a-z, 0-9, and the underscore character. The "g" (global) flag specifies that the search should find all occurrences of the pattern. The $1,$2,… property represents parenthesized substring matches.
Run the code and you should see the following output
Giving me +1 tells me you liked this article! Thanks in advance
Did you like this post?
|Save on Delicious|
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|