From 388f5d13abce7330e46ad2cc376d59f62ea7b4e6 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 16 Aug 2017 12:10:50 +0000 Subject: [PATCH] Better detection of allsign from general calls (CQ, QRZ ...) git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8027 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- decodedtext.cpp | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/decodedtext.cpp b/decodedtext.cpp index e81ea1d39..841f6ef53 100644 --- a/decodedtext.cpp +++ b/decodedtext.cpp @@ -3,40 +3,14 @@ #include #include - extern "C" { bool stdmsg_(const char* msg, int len); } QString DecodedText::CQersCall() { - // extract the CQer's call TODO: does this work with all call formats? - int s1 {0}; - int position; - QString t=_string; - if ((position = _string.indexOf (" CQ DX ")) >= 0) - { - s1 = 7 + position; - } - else if ((position = _string.indexOf (" CQDX ")) >= 0) - { - s1 = 6 + position; - } - else if ((position = _string.indexOf (" CQ ")) >= 0) - { - s1 = 4 + position; - if(_string.mid(s1,3).toInt() > 0 and _string.mid(s1,3).toInt() <= 999) s1 += 4; - } - else if ((position = _string.indexOf (" DE ")) >= 0) - { - s1 = 4 + position; - } - else if ((position = _string.indexOf (" QRZ ")) >= 0) - { - s1 = 5 + position; - } - auto s2 = _string.indexOf (" ", s1); - return _string.mid (s1, s2 - s1); + QRegularExpression callsign_re {R"(\s(CQ|DE|QRZ)(\s?DX|\s([A-Z]{2}|\d{3}))?\s(?[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"}; + return callsign_re.match (_string).captured ("callsign"); }