QRegExp
-
Hi Team,
I need to write the QRegExp such that it should work for the below.
Accepted input
TS R01L(single word)
TS RWY01L(single word)
TS R01L TS R02L TS R01R (Repeated word TS RO1L)
TS RWY1L TS RWY02L TS RWY01R(Repeated word TS RWY1L)Failure Input (I don't know the regExp for the below check)
TS R01L TS RWY02L( COmbination of .. R.... RX....... should through the error)
TS RWy01L TS R02L( COmbination of .. RX.... .. R....... should through the error)i write with two separate QRegExp.But I could not write combination of the two.
QRegExp m_rxWindShearRwy,m_rTearShearRwy;
m_rxTearShear.setPattern("(TS\sR\d{2}(L|C|R|)?)\b");
m_rTearShearRwy.setPattern("(TS\sR\d{2}(L|C|R|)?)\b");Please help me to resolve this.
I creates a simple qt project with QLineEdit,QLabel,QPushButton and assume that InputValue is typed in the QLineEdit and user clicked on the clickMe button, it should validate the above condition.
Please help me.since i could not i upload the,i didn't upload it
-
Hi,
Unless you are using Qt 4, please move to QRegularExpression as QRegExp should be considered deprecated.
As for developing your regex, build and run the https://doc.qt.io/qt-5/qtwidgets-tools-regularexpression-example.html).
As for your problem should the "base unit" be "TS something" ?
-
Hi,
Unless you are using Qt 4, please move to QRegularExpression as QRegExp should be considered deprecated.
As for developing your regex, build and run the https://doc.qt.io/qt-5/qtwidgets-tools-regularexpression-example.html).
As for your problem should the "base unit" be "TS something" ?
-
@sp0567
If you have two separate regular expression patterns, P1 and P2, and you want either of them to be acceptable, you can always combine them into a single expression by using the|
("OR") like:(P1)|(P2)
.Having said that, it looks to me as though your two are identical already? I can't see any differences.... And if they are
TS\sR\d{2}(L|C|R|)?)\b
it looks to me that is illegal,(L|C|R|)
has an unacceptable trailing|
?When developing complex regular expressions, a site like https://regex101.com/ can help you play more easily than in code. It won't have exact support for
QRegExp
, but should be close enough that you can deal with any particular differences. -
You then have the corresponding tool for QRegExp.