Could you help me with a regex to change lines like
<string name="Final time">Final time</string>
<string name="After extra time">After extra time</string>
to lines
<string name="final_time">Final time</string>
<string name="after_extra_time">After extra time</string>
So between double quotations replace space with underscore and make all letters lowercase.
I will use this regex with search/replace in VIM.
A generic approach:
This replaces every string @name that
\u) and\([^" ]\+\) \([^" ]\+\)) and\l\2\e).To make everything in @name lower-case, this could be simplified:
To get rid of multiple spaces, do two steps. First, make the attribute value lower-case:
then, replace every space in the attribute value with an underscore
Note that the
\@<=is vim’s way of expressing a positive look-behind assertion.