I have line of code like this one:
variableInCamelCase <- map["variableInCamelCase"]
I need to make it like this:
variable_In_Camel_Case <- map["variableInCameCase"]
Only the first word must be converted, I'm trying to find a regex to do it, and I need to do it in Vim but I can't. A regex like this one:
var rex = /([A-Z])([A-Z])([a-z])|([a-z])([A-Z])/g;
"CSVFilesAreCoolButTXT".replace( rex, '$1$4_$2$3$5' );
Is not good because I need to do it only on the first word. Plus, I need it for VIM which uses a special syntax to capture a group.
I tried something like this: s/\(\l\)\(\u\)/\1_\2/g
, which is equivalent to ([a-z])([A-Z])
, but I can't put it in OR with the ([A-Z])([A-Z])([a-z])
There is someone with a good vim ready regex for my problem? An explanation would be welcome also.