Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
How do I split hex encoded string into substrings of 2 characters? Example: "806982" -> "80", "69", "82".
I tried:
QString s = "806982"; QRegExp re("[\\da-fA-F]{2}"); // exactly 2 hex digits QStringList l = s.split(re);
but it did not work as intended.
You can use a regular expression in a loop:
QString s = "806982"; QRegExp re("([\\da-fA-F]{2})"); // exactly 2 hex digits QStringList l; int pos = 0; while ((pos = re.indexIn(s, pos)) != -1) { l << re.cap(1); pos += re.matchedLength(); }