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
0
votes
1 answer

QRegExp not matching as expected

i would like to match all strings that contain none of these characters "<",">","=" with QRegExp (Qt). With the folloing regexp, this is not working: "^[^><=]+$" why? to me it means: beginning of string, one or more characters that are not >,<,=…
kiriloff
  • 25,609
  • 37
  • 148
  • 229
0
votes
1 answer

Qt and regular expressions

I would like to write simple regexp with Qt QRegExp I want to fetch all substring of a Qstring with table(i, d), without the quotes, with i "hard written" and d representing any integer. And then using cap, to retrieve value for d. I propose …
kiriloff
  • 25,609
  • 37
  • 148
  • 229
0
votes
1 answer

Using regular expressions to get each item in a list

How can I use QRegExps to find each item in a list? What I am trying to do is to get each team in a list. They must be separated by a comma or a comma and space. For example, I want to get each team in this list: Patriots, Celtics, Red…
ZERO
  • 316
  • 7
  • 16
-1
votes
1 answer

QRegularExpression: how to get the failing position?

I guess that this has had to be asked before, but cannot find anything about it. I also think that maybe the answer is just right there but I can't see it either. So, if QRegularExpression::match() has not a match, how do I know the position of the…
Alvein
  • 167
  • 1
  • 9
-1
votes
2 answers

How to pass Philippine Currency in QRegExp?

I am currently studying Regex and I came up in this regex: r"\₱[0-9]*[.]{,1}[0-9]{,2}" for QRegExp is and currently It is only good if it starts with ₱ other than that my app is breaking is there a way to get these following…
-1
votes
2 answers

Javascript RegExp issues?

I've been trying hard to solve a problem using Js. I must define a function using RegExp that allows only 3 char words in which: The first two characters must be between a-z, excluding b The last character must be z or v Tried to build many…
-1
votes
1 answer

Regex - Private subtags RFC5646

Can someone please help me with a regex to pull out subtags from a RFC5646? Example strings en-us-x-test-test1 = test,test1 en-gb-x-test-test2 = test,test2 fr-x-test-test3 = test,test3 I'm using a QRegExp Thanks for any assistance
Daniel Robinson
  • 376
  • 4
  • 10
-1
votes
2 answers

Regular expression QRegExp

I need RegExp expression, which selects each letter once in the sentence (case insensitive). Can you help me? Input string is: AaAaaAaaabbacdaasccasddasdascasdasZz Result must be (in any order): abcdsz UPD: ok, i got it. No RegExp solution.…
warchantua
  • 1,154
  • 1
  • 10
  • 24
-1
votes
2 answers

Can't find the right regexp

I'm working with QString (Qt 4.8) and I want to extract this kind of string src="http://media.cineblog.it/9/91f/Big-Bad-Wolves-primo-trailer-per-il-crime-thriller-israeliano.jpg" from QString using QRegExp. But I can't find the righ regular…
-2
votes
1 answer

How to write regexp which will validate the following strings?

I have tried following regexp in cpp ^((T[X-Z]|R[X-Z])+?)(?:,\\s*|$). It validates only TX. If empty string it should be invalid, it should not accept numbers as well User may enter: TX TX, TY TX, TY, TZ, RX, RY, RZ RX It should be valid in…
-2
votes
2 answers

Validating integer part of an string

I have a text file that I need to convert each line into integer. The lines can begin with '#' to indicate a comment. Also, after the data it might be inline comment too...again indicated by '#' So I have the example below: QString time = "5000…
DEKKER
  • 877
  • 6
  • 19
-2
votes
1 answer

Regexp for array of numbers both float and integers separated by comma

I have to limit the data entered in the text box using the regexp for the following: Exs: 1,2,3 2.2,3.1,3 and if the user leaves the text box after entering 1.2,2,3. I have to remove the dot after 3 and save. I started of restricting to enter…
jxgn
  • 741
  • 2
  • 15
  • 36
-2
votes
2 answers

How to filter text file content using QRegExp?

I have a text file containing these lines: a1 b00 2222 a1 b01 233 a1 b92 34444 a2 b00 2222 a2 b00 3333 a2 b01 3333 I want to read this file and filter the text using QRegExp and fill the result…
Waleed A
  • 95
  • 10
-3
votes
1 answer

How to match string behind character in QT using RegExp?

How to match every String behind ":"? For example: want to match "3.23423" in "roll:3.23423" or "true" in "smth:true".
user1824542
  • 225
  • 1
  • 4
  • 15
-4
votes
2 answers

Extract string matching a specific format

Given a QString, I want to extract a substring from the main string input. e.g. I have a QString reading something like: \\\\?\\Volume{db41aa6a-c0b8-11e9-bc8a-806e6f6e6963}\\ I need to extract the string (if a string with the format exists) using a…
CybeX
  • 2,060
  • 3
  • 48
  • 115
1 2 3
12
13