I am writing a program which can trace depth of curly braces in a code file line by line, the idea is to have a global variable incremented every-time i find {and decremented every time i find }, this is easy and I already have it done, Now I want to to make sure that I don't count the braces that are inside quotes (i.e. string) or when it's in a comment (
или/ * */), я думаю, чтобы использовать силу режима в этой проблеме, но я не уверен, как должна выглядеть такое регулярное выражение, я думал что -то вроде «{//^»/"/" " Но это не правильно, любые идеи?
Подробнее здесь:
https://stackoverflow.com/questions/426 ... e-using-re