Can I see some simple examples of regular expressions in C++?
I’m trying to search for some good examples of regular expressions in C++, so I came here. Nothing really complex, just simple, because I’m learning. Maybe some example code for checking whether the first two characters of a string are digits, and whether the rest are lower-case letters? Really, anything would be fine.
I also have another question about QRegExp. Do I have to use it with Qt Creator, or can I just do it the classic way?
7 replies
Did you read QRegExp class reference [developer.qt.nokia.com] ?
Qt libraries are not bound with Qt Creator so you can use QRegExp with any IDE.
Okay, thanks for linking me there. I have a question about setting QRegExp values though, because it seems that you can’t set them using the ‘=’ sign. For example, this works:
QRegExp regexp1(”^[0-9]*$”);
..but this doesn’t..
QRegExp regexp1 = “^[0-9]*$”;
Are there any reasons why they don’t work? And since I’m used to using an ‘=’ sign to set my values, is there any way I can still set them using the ‘=’ operator?
In particular, have a look at the Code Examples [developer.qt.nokia.com] section, which I think probably has the simple sort of regex examples you are looking for (assuming you already know a bit about regular expressions, and are just looking for info on implementing them using QRegExp).
You must log in to post a reply. Not a member yet? Register here!



