Regex to ignore commented lines C++ -
I am trying to use regex to find all the variable initializations or assignments in the code. Currently I have
(\ w + | \ [_]) \ s * = \ s * (\ d + \. \ D + .. *)
which works but also comments like code like // a = 100;
which I do not want to do I have tried
([^ /] \ w + | \ [_]) \ s * = \ s * (\ d + \. \ D + .. *) `
Which I thought was to ignore strings which starts with / but it does not work.
Edit:
For example I want to find it like b = 200;
but // c = 3;
I try to take it if necessary.
^ (?!!! / / /). * [Az] [a-z0-9 \ _] * \ s * = \ s * [0-9] + ;
View the demo:
Comments
Post a Comment