Questions tagged [qregexp]

QRegExp is a Qt class that provides the functionality of regular expressions.

The QRegExp class provides pattern matching using regular expressions in the Qt framework.

The default regular expression syntax in QRegExp is modeled after Perl (PCRE), but it supports some other syntaxes as well.

Note: Qt 5+ offers a more modern regex implementation though the QRegularExpression class.

Usage example for finding all numbers in a string:

QRegExp rx("(\\d+)");
QString str = "Offsets: 12 14 99 231 7";
QStringList list;
int pos = 0;

while ((pos = rx.indexIn(str, pos)) != -1) {
    list << rx.cap(1);
    pos += rx.matchedLength();
}
// list: ["12", "14", "99", "231", "7"]

Read on in the official Qt documentation for Qt 4.8 and for Qt 5.

181 questions
-4
votes
1 answer

Perl regular expression to remove leading and trailing whitespace of each column in a string

I have a requirement to remove the leading and trailing spaces in each column of a string delimited by "|" TEST| 100| 0.00 |TEST STRING I am using the following regular expressions to remove the spaces, but it does not seem…
senthilkumar
  • 13
  • 2
  • 5
1 2 3
12
13