[SOLVED]Regular Exp help
I am new to regular expressions and would appreciate some help.
I need to match the the string "TestUI_xx.txt", where 'xx' mut be 2 alphabetical characters, but cannot see how to do this.
I would be grateful if someone could point me in the right direction
the "QRegExp":http://qt-project.org/doc/qt-4.8/qregexp.html documentation contains all you need for that.
Here's what you basically need:
There also the very useful Regular Expression Example that you can build to test/validate your regexp.
If you're using Qt 5 there's also the QRegularExpression class
Hope it helps
Thanks very much - works like a charm
To point you in the right direction, read the documentation on Regular Expressions in Qt:
- QRegExp in "Qt 4.8":https://qt-project.org/doc/qt-4.8/QRegExp.html or "Qt 5.0":http://qt-project.org/doc/qt-5.0/qtcore/qregexp.html
- QRegularExpression in "Qt 5.0":http://qt-project.org/doc/qt-5.0/qtcore/qregularexpression.html
For Qt 5 I think QRegularExpression is preferred, see "this":https://qt-project.org/wiki/Regexp_engine_in_Qt5 link.
I did use the documentation on 4.8 to learn the basics of Regular Expressions so that would be a good starting point. I still refer back to that page when doing RexExps.
If you understand Regular Expressions and patterns, you can use the "Regular Expression" example application in Qt Creator to test a pattern before you implement it in an application.
To give you the answer:
The pattern you need should be something like:
What should the output be of your match?