[Qt-interest] Using QRegExp
Christoph Keller
gri at not-censored.com
Sun Mar 21 16:55:35 CET 2010
Hello,
when testing regular expressions for Qt, I'm using the Regex Coach
(http://weitz.de/regex-coach/) and verifying is done by the Qt Regular
Expression Example (QTDIR/examples/tools/regexp). There you can turn
around the RegExp types until it fits your needs. Escaping is also done
for you.
Hope this helps.
Greetings,
Christoph
PS: I've never used QString::split() with a RegExp, always done this by
QRegExp::indexIn()
Am 21.03.2010 16:05, schrieb Robert Hairgrove:
> I'm trying to split up email headers into their corresponding fields
> using regular expressions.
>
> In a text editor which supports regular expression search and replace
> (UltraEdit), I can use "^[\S]*:" as the regexp (for QRegExp it would be
> "^[\\S]*:") and it matches all of the field names nicely while ignoring
> the colons in the timestamps.
>
> However, when I try to use this same expression with QString::split(),
> it finds the first occurrence (i.e. header field name) but ignores all
> the rest. The input is the entire header which is contained in one
> QString object with embedded newlines.
>
> Does the "^" tag work only at the beginning of a string and not after
> embedded newline characters? I suppose I could split the string at the
> newline character and iterate over the resulting QStringList members,
> but then I have to watch out for folded header lines (RFC 822 -
> http://tools.ietf.org/html/rfc822 - at par. 3.4.8 on page 15 explains
> about folded header fields).
>
> Any advice here would be most welcome!
More information about the Qt-interest-old
mailing list