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:
QString town_code; QRegularExpression re1("code=(.+)\\s"); QRegularExpressionMatch match = re1.match (a_text); hasMatch = match.hasMatch(); if (hasMatch) { town_code = match.captured(1); ............ ............ ............ }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.
Bookmarks