diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2020-10-27 18:39:24 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2020-10-27 18:39:24 +0000 |
| commit | 89f38b68c3a0c4a85b755006bf602d76fdc37875 (patch) | |
| tree | 674619678c1136c4b4503ff356f6d8a150a3758b /src/plugins/PlayListFormats/m3u | |
| parent | 81170fffef768feee0c91ae953f2c05d1fed6a75 (diff) | |
| download | qmmp-89f38b68c3a0c4a85b755006bf602d76fdc37875.tar.gz qmmp-89f38b68c3a0c4a85b755006bf602d76fdc37875.tar.bz2 qmmp-89f38b68c3a0c4a85b755006bf602d76fdc37875.zip | |
ported all remaining code to QRegularExpression
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9532 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/PlayListFormats/m3u')
| -rw-r--r-- | src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp index 95e2bae91..29eb042e0 100644 --- a/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp +++ b/src/plugins/PlayListFormats/m3u/m3uplaylistformat.cpp @@ -20,6 +20,7 @@ #include <QFileInfo> #include <QtPlugin> +#include <QRegularExpression> #include <qmmpui/metadataformatter.h> #include "m3uplaylistformat.h" @@ -39,8 +40,8 @@ QList<PlayListTrack *> M3UPlaylistFormat::decode(const QByteArray &contents) if(splitted.isEmpty()) return out; - QRegExp extInfRegExp("#EXTINF:(-{0,1}\\d+),(.*) - (.*)"); - QRegExp extInfRegExp2("#EXTINF:(-{0,1}\\d+),(.*)"); + QRegularExpression extInfRegExp("#EXTINF:(-{0,1}\\d+),(.*) - (.*)"); + QRegularExpression extInfRegExp2("#EXTINF:(-{0,1}\\d+),(.*)"); int length = 0; QString artist, title; bool hasExtInf = false; @@ -51,17 +52,19 @@ QList<PlayListTrack *> M3UPlaylistFormat::decode(const QByteArray &contents) if(str.startsWith("#EXTM3U") || str.isEmpty()) continue; - if(extInfRegExp.indexIn(str) > -1) + QRegularExpressionMatch match; + + if((match = extInfRegExp.match(str)).hasMatch()) { - length = extInfRegExp.cap(1).toInt(); - artist = extInfRegExp.cap(2); - title = extInfRegExp.cap(3); + length = match.captured(1).toInt(); + artist = match.captured(2); + title = match.captured(3); hasExtInf = true; } - else if(extInfRegExp2.indexIn(str) > -1) + else if((match = extInfRegExp2.match(str)).hasMatch()) { - length = extInfRegExp.cap(1).toInt(); - title = extInfRegExp.cap(2); + length = match.captured(1).toInt(); + title = match.captured(2); hasExtInf = true; } |
