[Interest] QRegExp help: boundaries
Sensei
senseiwa at gmail.com
Wed Mar 27 11:28:48 CET 2013
Dear all,
I am trying to use QRegExp to find if a string contains a latex command,
but I'm puzzled on how to do that.
In particular, for those who don't know latex, commands are (simplifying
a lot) words starting with a backslash \ and using curly parentheses {}
(and brackets []). For example
\documentclass[11pt]{article}
Now, I'd like to find that command. I wanted to use a QRegExp, in
particular this code:
if (s.indexOf(QRegExp("\b\\\\documentclass\b")) > -1)
However, I get no luck with word boundaries. In fact, a string like the
one I wrote as an example of latex, isn't recognized. I need word
boundaries because I want to discern between
\documentclass{article} <--- GOOD
\documentclasss{article} <-- BAD
\documentclass {article} <-- GOOD
etc.
Any hint? I'm not THAT familiar with regexps, though!
Thanks & Cheers!
More information about the Interest
mailing list