c++ - QSyntaxHighlighter highlight part of match with QRegExp -
i needed match string following:
- 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
Post a Comment