I am working on a C++ code base that was recently moved from X/Motif to Qt. I am trying to write a Perl script that will replace all occurrences of Boolean (from X) with bool. The script just does a simple replacement.
s/\bBoolean\b/bool/g
There are a few conditions.
1) We have CORBA in our code and \b matches CORBA::Boolean which should not be changed.
2) It should not match if it was found as a string (i.e. "Boolean")
Updated:
For #1, I used lookbehind
s/(?<!:)\bBoolean\b/bool/g;
For #2, I used lookahead.
s/(?<!:)\bBoolean\b(?!")/bool/g</pre>
This will most likely work for my situation but how about the following improvements?
3) Do not match if in the middle of a string (thanks nohat).
4) Do not match if in a comment. (// or /**/)