I’m writing an IDE for Python language in C++ and I have wrote a syntax highlighter for Python language syntax. but i have two problems with it:
-
my regular expression pattern for highkighting numbers is ‘\d+’. it highlights numers everywhere in code. for example it highlights ‘4’ in ‘Qt4’ and i want to it doesn’t highlight numbers in such cases.
-
my regular expression pattern for highkighting strings between two ‘”‘ is ‘\”.*\”‘. it works but with one problem.
it even highlights cases as ‘”some text1″ some text2 “some text3″‘ and i want to it doesn’t
highlight ‘some text2’.
what is solution for these two problems?
As already mentioned in the comments it may not be appropriate to use regular expressions to parse a language.
Regarding your two questions:
\b\d+\b\".*?\"Note: As already mentioned those are only workarounds and may not be correct in any case.