teamikl/wahjam — comment on commit f00650f107a67f90a77588e934235ee54a4970e8
File: ninjam/qtclient/ServerBrowser.cpp line 50
By stefanha:

This can be done more concisely with a regular expression:

```c++
void ServerBrowser::parseServerList(QTextStream *stream)
{
QRegExp serverPattern("SERVER\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\".*");

while (!stream->atEnd()) {
if (!serverPattern.exactMatch(stream->readLine())) {
continue;
}

QTreeWidgetItem *item = new QTreeWidgetItem(this);

item->setText(0, serverPattern.cap(1)); // server
item->setText(1, serverPattern.cap(2)); // bpm/bpi
item->setText(2, serverPattern.cap(3)); // member list
}
}
```

Note that I put .* at the end of the expression so new fields can be added to the serverlist format without breaking this parser.