Questions tagged [qregularexpression]

The QRegularExpression class in Qt 5 and 6 provides pattern matching using regular expressions. This tag is for questions about the use of regular expressions in the Qt library. For generic questions about regular expressions, use the "regex" tag.

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

The regular expression syntax in QRegularExpression is modeled after Perl (PCRE).

Note: This class is new in Qt 5. Qt also offers an older, slightly less capable regex implementation though the QRegExp class.

Usage example for finding all numbers in a string:

QRegularExpression re("(\\d+)");
QString str = "Offsets: 12 14 99 231 7";
QStringList list;
QRegularExpressionMatchIterator i = re.globalMatch(str);

while (i.hasNext()) {
    QRegularExpressionMatch match = i.next();
    list << match.captured(1);
}
// list: ["12", "14", "99", "231", "7"]

Read on in the official Qt documentation for Qt 5.

120 questions
-1
votes
1 answer

Regular expression

I have a document, and I need to find all the words(no spaces) borded with '. (e.g. 'apple', 'hello') What would be the regular expression? I've tried ^''$ but it didn't work. If there isn't any solution, it could not be "any word" but also it can…
Andrew
  • 3
  • 1
-1
votes
1 answer

need to check following string formats are correct or not using regular expression

How can I check following string is in valid format or not? Can someone provide me regular expression to check this. Expect format should be like :: key:valu;key2:value2; Following are some valid and invalid strings I want to check. k1:v1;k2:v2; =>…
-1
votes
1 answer

Can't find any explanation for QRegularExpression behavior. It works, but it shouldn't

As the question implies I have a code snippet, with QRegularExpression, which works. It does what it is supposed to do, causes no errors and everything is fine. Why am I posting the question? Well everything that I found so far implies that my…
-1
votes
1 answer

POSIX Regex notation to start and end with @ and Regex notation to have alphanumeric chars but Must contain an _

I currently using regex.h for a c program wanted to ensure a string starts and ends with the @ which surrounds alphanumeric chars, (only 2 @'s none in the middle) UPDATE: I think i fixed the first question by using the ^ and $ anchor tags. If that…
-1
votes
1 answer

Regular expression for excluding some specific characters

I am trying to build a regular expression in Qt for the following set of strings: The set can contain all the set of strings of length 1 which does not include r and z. The set also includes the set of strings of length greater than 1, which start…
Sumeet
  • 8,086
  • 3
  • 25
  • 45
-1
votes
1 answer

how to fetch a complex substring using qt?

I am working my hands on QT and c++. As part of a test project, i need fetch a substring from a complex and long string, basically it is a source of a webpage. If my question looks very trivial then it would be because i am a naive qt programmer and…
Noddy
  • 33
  • 1
  • 1
  • 9
-1
votes
2 answers

Regular Expressions find all values inside asterisk

i need to find all values that resides between two asterisk symbol *data1* *data2* *data3* *data4* *data5*how do i set Regular Expression in java for this particular string. i tried indexof ..but it ain't work
sarath kumar
  • 134
  • 4
-2
votes
1 answer

replace exact null string either startswith dot charector . or endswith . dot charector or its not appended to any other string ,it should b separate

I was trying replace null , .null or null. string from below code snippet static String str1="WTDocument: null ( 0000000043 ) A.1"; static String str2= "WTPart: null ( WHEEL_A1 ) null.null"; static String str3= "WTPart: null ( WHEEL_A1 )…
-2
votes
1 answer

How QRegularExpression can be passed to Qt::MatchRegularExpression

I am trying this sample code that I found which is really really good. I am also trying to figure out the same thing to find an item and scroll to it, but this time I wanted to match the the string which has the EXACT WORD "cat". Example…
Ice Bear
  • 2,676
  • 1
  • 8
  • 24
-2
votes
1 answer

Perl Regural Expression | How to use negative lookahead(?!) inside a non capturing group (?:)

I want to use a negative look-ahead inside a non capturing group in Perl Regex. So far i have create an expression that not allows 3 "pairs of characters" into a string CASE 1: ^(?!(?:\w*(.)\1){3}).+$ For example the string: Mytte!3sttStrring |…
Nikos Kalantas
  • 95
  • 4
  • 11
-2
votes
2 answers

Regular Expression To exclude sub-string name(job corps) Includes at least 1 upper case letter, 1 lower case letter, 1 number and 1 symbol except "@"

Regular Expression To exclude sub-string name(job corps) Includes at least 1 upper case letter, 1 lower case letter, 1 number and 1 symbol except "@" I have written something like below : ^((?!job…
Kapil
  • 1,823
  • 6
  • 25
  • 47
-3
votes
1 answer

Regular expression for value Range from 1 - 1440 (Integer)

What will be the regular expression for value Range from 1 - 1440? (Integer)
-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
-4
votes
1 answer

How to search this kind of pattern in regex

This is the sample text I want to get the regex of the Match specified string that regex will qualify the Not match conditions 1abc.def.ghi (Match) abc.111.ghi (Match) 123.123.123.132.123.123…
Ajil Raju
  • 37
  • 1
  • 2
  • 9
1 2 3 4 5 6 7
8