I'm parsing .h
and .cpp
files and I need to find/replace all non-Hungarian notated variables with their Hungarian equivalents. "Augh, why?!" you ask? My employer requires Hungarian notation, 'nuff said.
Let's just deal with ints
for now.
Given any of these cases...
int row; // no hungarian prefix
int nrow(9); // incorrect capitalization
int number; // hmm...
int nnumber = getValue(); // uh oh!
They should be changed to:
int nRow;
int nRow(9); // obviously ctor args and assignments shouldn't change
int nNumber;
int nNumber = getValue();
I'm shooting for just a single one-line call to s///
ideally.
For added challenge, if someone can get something to change ALL instances of this variable after the "type check" with int
, that would earn you some brownie points.
Here's what I have so far:
s/(int\s+)(?!n)(\w+)/$1n\u$2/g;
This doesn't match things like int nrow
or int number
though.
Thanks in advance!