c++ - QSyntaxHighlighter highlight part of match with QRegExp -


i needed match string following:

  1. xxx

but both "1." , "xxx" highlighted , , i'm using following regex:

qregexp ("^\s+(\d+\.)?\s+\b[a-z]{2,}\b")

how can highlight xxx in case ?

many !

your regex should like:

qregexp ("^\s+(\d+\.)?\s+(\b[a-z]{2,}\b)") 

so can capture xxx in regex. then, retrieve matches using capturedtexts(). string you're after should last index since first item entire string matches, second 1 number , dot if found or string xxx. if number present, xxx in third string.

having that, can find index of substring inside original 1 setup highlighting.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -