it is actually, but i searched and never found it probably due to the obscure name. Id suggest keeping this open so people can actually find the answer. "RegExp $1 to uppercase"... no one is going to find it unless they already knew regex IMO
–
Oscar GodsonJul 12 '11 at 7:56

That was easily fixable. I just edited the title
–
mplungjanJul 12 '11 at 8:13

I think that the parameter should be renamed to "m", like "match". One can quickly write something like : myString.replace(/-([a-z])/i, function (i) { return i[1].toUpperCase() });
–
programathsJul 15 '13 at 14:34

1

It would be a good idea to make your regex more robust by adding the i flag. Without it, your pattern misses "capitalized-Parts" (won't be changed into "capitalizedParts"). Also, I personally prefer the improved readability of multiple parameters, but that's obviously a matter of style. All in all, I'd go with .replace( /-([a-z])/gi, function ( $0, $1 ) { return $1.toUpperCase(); } );.
–
hashchangeMar 6 at 11:35

I don't see the point IMHO: The use of camelCase vs hyphen seperated identifiers is over debated I know, but I would like to share a recent observation: When editing the identifier in a text editor, it is easier to edit a hyphen separated identifier as apposed to camelCase.

Reason?

A double click on "first" in "first-name" selects only the first in the event that you may wish to refactor it to "last-name" this ensures that only the part that is relevant will be changed.

Using camelCase would require a full word edit in the case of lastDayOfMonth when instead you could just change it (if using hyphen) by double-clicking the "first" in "first-day-of-month" and changing it to "last" to get "last-day-of-month". It's a matter of taste of course, but notice that you provided for easier editing of code for perhaps others.

Secondly it's a habit that pays off when it comes to naming files that may get displayed in urls. I prefer to read hyphen separated file names in a url.

I wont rate you down because you dont have many points, but you'll probably get marked down other places if you dont give an actual answer. If the OP is asking something and it's a bad idea provide the code to do it, and then explain why you shouldnt do that, and then maybe provide better code. :)
–
Oscar GodsonAug 24 '11 at 18:48

This is really old, but this was for the Google Maps API. The options were set in HTML but I needed to convert them to match the APIs option names. Simply quoting it wouldnt match Googles options so it wouldnt help.
–
Oscar GodsonMar 20 '14 at 8:05