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

setMinimal equivalent in QRegularExpression

I am porting some Qt5 code to Qt6, which requires switching QRegExp to QRegularExpression. The Qt5 code uses the setMinimal(bool minimal) method of QRegExp. Is there an equivalent PatternOption in Qt6? I see a…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

QRegExp a filename but its not matching

I'm trying to parse date time from a PNG file but can't quite get it with QRegExp this_png_20211208_1916.png QDateTime Product::GetObstime() { QDateTime obstime; QString filename = FLAGS_file_name.c_str(); QString year,…
0
votes
2 answers

Ruby expression to check for a string in fluentd filter

I need to create a new field 'status' if the log field contains a specific string. I tried below code in fluentd but this doesnt work. I need to check if the log field contains the string 'error:' then the new field status should have error else if…
0
votes
1 answer

QLineEdit unexpected behavior using QRegExpValidator

I'm using a QLineEdit widget to enter email addresses and I set up a QRegExpValidor to validate the entry. The validator is working as far as preventing the input of characters not allowed in the QRegExp, but funny enough, it allows to enter…
Erick
  • 301
  • 3
  • 12
0
votes
1 answer

Need QRegEx logic to split number bullet

I am trying to build a QRegEx logic to split number bullet. I tried but couldn't succeed. sample code: QString query("1. Ravi Gupta.Pari.Paagal"); QStringList list = query.split(QRegularExpression("\\(.*?\\)")); qDebug()<<"Output:…
RaviS Gupta
  • 95
  • 2
  • 11
0
votes
2 answers

How to combine RegEx conditions?

I need to make a QLineEdit with a QRegularExpressionValidator with the following 3 constraints: Cannot start with empty space ^[\\S] Cannot start with Hello ^(?!Hello).+ Cannot end with empty space ^.*[\\S]$ How do I combine those 3 in one regex…
santahopar
  • 2,933
  • 2
  • 29
  • 50
0
votes
1 answer

Regular expression of Qt don't match as expected

Why is the regular expression of Qt a little different? I can match correctly in regular matching software, but not in Qt. For example. QString tstring = "scale(1.1) rotate(180) translate(1,0)"; QRegExp re("(?<=[\\)])."); QStringList tlist =…
sorrowfeng
  • 17
  • 6
0
votes
0 answers

Improperly nested brackets regexp

I need a regexp that will find improperly nested brackets, not properly. For example: ()(( — matches regexp (()) - doesn't match regexp ))((( — matches regexp etc.
Victor
  • 1
0
votes
1 answer

Is there a more efficient way to generate a REGEX String for Dates

I am looking for a more efficient Regular Expression for a QT Project. Date Strings to which the following regular expression matches: 8 June 2009 2009-06-08 1/31/1971 ca. 1971 circa 1971 about 1971 abt 1971 before 1971 bef 1971 bante 1971 after…
Tim P
  • 69
  • 1
  • 9
0
votes
1 answer

QRegExp containing line feed, enter

I have no clue how to use QRegExp. I am trying to remove selected characters from QString but don't know how to write it as regular expression, never worked with those :( I want to remove all line feeds, enters, |, ¦, ¶ and §. Thanks Ps: I wish to…
krizajb
  • 1,715
  • 3
  • 30
  • 43
0
votes
1 answer

QRegExpValidator parameters

If I write the following: QValidator *validator = new QRegExpValidator(regExp, this); What does this mean here? What is it referring to? If I don't use it what effect will occur?
Simplicity
  • 47,404
  • 98
  • 256
  • 385
0
votes
1 answer

QRegExp not matching anything

I've an application made by another person and I need to fix it. There's a chart on the view and a textbox for filtering the chart but filter doesnt work. For some reason QRegExp cant find anything. I am using QT5.12.1 and VS2015. void…
Jeredriq Demas
  • 616
  • 1
  • 9
  • 36
0
votes
1 answer

Why QRegExp matches this regular expression?

I found regular expression which should match IPv4 address: QRegExp rx_ipv4("^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])$"); bool match = rx_ipv4.exactMatch("1.2.33333"); It returns true. But in above…
StackPeter
  • 324
  • 2
  • 10
0
votes
1 answer

QregExp class PyQt4

I am trying to achieve the following, however with the QRegExp class in PyQt4. I am struggling to find good examples on how to use this class in python. def html_trap(text): h ={"&":"&",'"':""","'":"'",">":">","<":"<"} …
the_big_blackbox
  • 1,056
  • 2
  • 15
  • 35
0
votes
1 answer

How to setBold for matching characters with QSortFilterProxyModel?

This is an example on Qt Website In this case the matching characters are not bold, and other characters are bold. I want to do the other way around: the matching characters should be bold and others are not bold. How can I do…
songvan
  • 369
  • 5
  • 21