QRegularExpression question
I want to match strings using QRegularExpression, but it seems that the RegExp doesn't like the pattern I'm using.
I have a pattern like "foo \S is a \S", which should match both "foo blah is a bar" and "foo blah is a very big boat" .... but doesn't seem to like either. I tried a simple "the \S" against "the quick fox", that's good... but "the \S fox" doesn't match "the quick fox". Is this an impossible pattern to use?
Thanks,
Vycke
Re: QRegularExpression question
Are you escaping the backslash in your string literal? If not, then your expression is looking for "foo S" literally and not finding it.
Re: QRegularExpression question
I am escaping the S. (trying something, it may be the S is looking for a single char)
Re: QRegularExpression question
I didn't ask about the S. The compiler will convert the string literal "foo \S" into "foo S" inside the program. If you want the regex to read "foo \S" after the compiler has done its thing then your code should read "foo \\S"
Re: QRegularExpression question
It is. I have been coding for nearly 15 years (yeouch)... this is a question about the QRegularExpression part.
Vycke
Re: QRegularExpression question
The \S in your regex has the meaning any single non-whitespace character. Presumably you mean one or more as in:
foo \S+ is a \S+