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
2
votes
3 answers

Capture multiple texts.

I have a problem with Regular Expressions. Consider we have a string S= "[sometext1],[sometext],[sometext]....,[sometext]" The number of the "sometexts" is unknown,it's user's input and can vary from one to ..for example,1000. [sometext] is some…
Evgenii.Balai
  • 939
  • 13
  • 30
2
votes
1 answer

Qt "QTextEdit" Functions

Well, i'm doing an IDE System. Basically, everything works Fine. Though, but i have a problem. The class "QTextEdit" doesn't have the member "setCompleter" which is for autocomplete. Right? Well, is some class that supports it including all…
Kazuma
  • 1,371
  • 6
  • 19
  • 33
2
votes
0 answers

'PySide2.QtGui' has no attribute 'QRegularExpressionValidator'

I am building a ASCIIValidator with the help of the Qt c++ source code which relies on the QRegularExpression classes instead of their old QRegExp counterparts. To make an example, please take a look at line 916 of…
2
votes
1 answer

qregexp extract all numbers from string

I'm quite noob with regular expression, all i want to do is to get all numbers from a string. QRegExp rx; rx.setPattern("\\d+"); rx.indexIn("this string contains number 123 and 567*872"); QStringList MyList = rx.capturedTexts(); Expected result is:…
emazed
  • 23
  • 7
2
votes
2 answers

Write only float values in QLineEdit

How to write in QLineEdit float numbers in range (0.0 - 5.0)? I use qregexp for such a task for example QRegExp a("([a-zA-Z]{3,30})") to write user name but have no ideas to write float numbers.
user8167852
2
votes
2 answers

Need assistance with Regular Expressions in Qt (QRegExp) [bad repetition syntax?]

void MainWindow::whatever(){ QRegExp rx (""); //QString line = ui->txtNet1->toHtml(); QString line = "Barfoo"; while(line.contains(rx)){ qDebug()<<"Found rx!"; …
Joseph
  • 12,678
  • 19
  • 76
  • 115
2
votes
1 answer

Using QRegExp to parse headers

I am parsing an email header using QRegExp my problem is if the header tag is multiline my regex won't work. Here is my regex: (I have \r\n has placeholders for now, ) QRegExp regex("([\\w-]+):…
2A-66-42
  • 554
  • 1
  • 5
  • 18
2
votes
1 answer

How to parse pacmd list output and find sink indexes and names using QRegExp?

Normally from the terminal I use the command: pacmd list-sinks|awk '/index:/ {print $0} /name:/ {print $0};' which gives me an output like this: index: 0 name: index: 1 name:…
the_naive
  • 2,936
  • 6
  • 39
  • 68
2
votes
1 answer

What use is QRegExp::pos() without a corresponding QRegExp::len() of sorts?

In a project I'm working on, I need to make a QStringList out of all QRegExp captures except for 2 of them: the 1st one and one of the other ones, depending on some other parameters. The straightforward approach would be to use…
Fabio A.
  • 2,517
  • 26
  • 35
2
votes
3 answers

QLineEdit IP partial validation

In my project I want to filter some of my data via IP input. I also want to allow to filter by partial IP input for example : 192.168. I found out how to set the complete IP validation. QString oIpRange; QRegExpValidator *poIpValidator; …
Simon
  • 1,522
  • 2
  • 12
  • 24
2
votes
2 answers

Why QString can not pass a QRegExp of the form ("[\\x00-\\xff]*")?

I have QRegExp with the following pattern QRegExp byteArray; byteArray.setPattern("[\\x00-\\xff]*"); This is patterns is used to validate QString's. Can some one provide example of what kinds of QString's can not pass this test for the pattern…
Neaţu Ovidiu Gabriel
  • 833
  • 3
  • 10
  • 20
2
votes
5 answers

Regular expression for double values using QRegExp

I am writing a regular expression checker for QLineEdit and I am using QRegExp. I have already wrote a int value checker: QRegExp *expression_ = new QRegExp("^(0|[1-9]{1,1}[0-9]{0,9}); But I have complications with double values, to be more…
Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
2
votes
4 answers

Match float numbers separated by semicolon

I use a regexp validator and I want to restrict the use of anything but the pattern: 5414.1;123;412.1;41241;... I tried to use [0-9;\.]* but I can't make it match only patterns which contain one(1) point after the text and before ;. I tested using…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
2
votes
2 answers

Extracting a scientific notation number using regexp in python

I'm trying to extract values from numerous text files in python. The numbers I require are in the scientific notation form. My result text files are as follows ADDITIONAL DATA Tip Rotation (degrees) Node , UR[x] , UR[y] , UR[z] 21 , 1.0744 …
user2739143
  • 591
  • 2
  • 8
  • 13
2
votes
1 answer

RegExp to find command line arguments

i am workin on a terminal program to execute applications on remote machines. you can pass a command like in the windows cmd.exe like: "C:\random Directory\datApplication.py" "validate" -r /c "C:\anotherDirectory" to make that possible i have to…
Zaiborg
  • 2,492
  • 19
  • 28
1
2
3
12 13