Hello.

Here is the code I use to extract a sub-string of unknown length. This character sub-string begins with the sequence code= and ends with a space.

Qt Code:
  1. QString town_code;
  2. QRegularExpression re1("code=(.+)\\s");
  3. QRegularExpressionMatch match = re1.match (a_text);
  4. hasMatch = match.hasMatch();
  5. if (hasMatch) {
  6. town_code = match.captured(1);
  7. ............
  8. ............
  9. ............
  10. }
To copy to clipboard, switch view to plain text mode 

The result is correct for variable a_text containing:
ARANTZAZU (OÑATI) code=onati-id20059 ville=OÑATI
The town_code variable contains the correct value: onati-id20059


The result is incorrect for variable a_text containing:
OTSAURTE (ZEGAMA) code=Zegama-id20025 ville=ZEGAMA tameteo=http://www.tameteo.com/meteo_Zegama-Europe-Espagne-Guipuscoa--1-3385.html
The town_code variable contains the incorrect value: Zegama-id20025 ville=ZEGAMA


Help is welcome.