[SOLVED] QRegExp help needed
-
I am having problems with the QRegExp in my client / server app. the following is what i currently have and it works good.
@// Normal messges look like this: "username:The message"
QRegExp messageRegex("^([^:]+):(.*)$");
QString user = messageRegex.cap(1);
QString message = messageRegex.cap(2);@in the above code, it brakes up the "username", and "The message" into two variables. the problem is that i need to add another variable to the list for the private chat. i would like it to be the following but it is not working. i am getting a bad message error.
@// Normal messges look like this: "username:tabName#The message"
QRegExp messageRegex("^([^:]+):([^#]+)#(.*)$");@in the client, I am trying to brake "username", "tabName" and "The message" into three different variables.
in the following code it reads from the client. if the message = -1 then give the error...
@QString line = QString::fromUtf8(client->readLine()).trimmed(); QRegExp meRegex("^/me:(.*)$"); if(meRegex.indexIn(line) != -1) { user = meRegex.cap(1); users[client] = user; } else if(users.contains(client)) { QString message = line; user = users[client]; } else { emit display("Got bad message from client:" + client->peerAddress().toString() + line); } }@