PDA

View Full Version : qregexp to check string



mattia
19th February 2008, 08:32
Hello, i have to validate this string "http://username:password@url:port" with a QRegExp.
I want that my regExp control if the string start with "http://" and contain 3 ":" occurrences and 1 "@" occurrences.

I get some problem to build the regExp, i started in this way:

"^[http://]+[:]{3}+[@]{1}" but it does not work...any hint?

jpn
19th February 2008, 08:40
How about using QUrl.

ChristianEhrlicher
19th February 2008, 10:04
Or using simple QString functions instead thinking about the correct regexp for hours.

vladeck
19th February 2008, 14:13
I will (probably) not help you with this reply, but using regex is better than using QString functions - you can build regex lineedit or some other control - checking for correct input of another string format is just regex away, while with QString parsing you would need to modify code each time - bad, bad, bad... there are nice examples on msdn, and there is regex building support in visual studio find dialog - maybe that will help you.