help on a vim search / replace complex regular expression
Here's what I'd like to do with a regular expression: 2 steps:
(1) transform all variables in a selected area like this:
$Sejour_deb_mois
$Info_pays
to :
$SejourDebMois
$InfoPays
(2) transform all variables in a selected area like this:
$this->Sejour_deb_mois
$this->Info_pays
to :
$this->SejourDebMois
$this->InfoPays
And 开发者_开发问答I'm pretty sure this can be done using a regular expression... but I can't figure out the two good ones that do the job...
Any help would be greatly appreciated!
Thanks
Olivier Pons
For both of the examples above, this should do the job:
s/\(_\)\(.\)/\u\2/g
Basically, it's finding every underscore and the following character, grouping them with the parens. Then, it discards the underscore and uppercases the one character.
If you've visually selected the region and pressed :
, the whole expression will look like:
:'<,'>s/\(_\)\(.\)/\u\2/g
精彩评论