Answer the question
In order to leave comments, you need to log in
How to find ip addresses in free text using QRegExp?
There is a certain html page with the list of ip addresses.
I'm trying to rip out these same addresses from it using Qt, or rather QRegExp.
Googled on the topic, but I just can not get the right answer from QRegExp.
An expression like this:
(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
gives an empty response. ([0-9]{1,3}[\\.]){3}[0-9]{1,3}
gives out only parts of the address, or rather Answer the question
In order to leave comments, you need to log in
QRegExp rx("(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})");
QString text("192.168.1.1 blah-blah 192.168.1.2 blah-blah");
int pos = 0;
QStringList list;
while ((pos = rx.indexIn(text, pos)) != -1)
{
list << rx.cap(1);
pos += rx.matchedLength();
}
192.168.1.1
192.168.1.2
QRegExp rx("(((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question