<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QRegularExpression with a character class behaving strangely]]></title><description><![CDATA[<p dir="auto">I'm trying to use QRegularExpression to extract Arabic text (0x600-0x6ff) from a string.  Below is the sample code and output. (I've included duplicate code that picks out latin lowercase letter just to convince myself that the method should work.)<br />
@<br />
QRegularExpressionMatchIterator iter;<br />
QRegularExpression regex("([\x61-\x7a]+)");<br />
qDebug() &lt;&lt; "lower case QRegularExpression pattern" &lt;&lt; regex.pattern() &lt;&lt; regex.isValid();</p>
<p dir="auto">iter = regex.globalMatch("the cow JUMPED over");<br />
while(iter.hasNext()) {<br />
QRegularExpressionMatch match = iter.next();<br />
if (match.isValid()) {<br />
qDebug() &lt;&lt; match.capturedTexts();<br />
}<br />
}<br />
QRegularExpression arabic("([\x600-\x6ff]+)");;<br />
qDebug() &lt;&lt; "arabic regex" &lt;&lt; arabic.pattern() &lt;&lt; arabic.isValid();<br />
iter = arabic.globalMatch("You say, كَتَبَ إِلَىَّ يَسْتَبْطِئُنِى He wrote ");<br />
while(iter.hasNext()) {<br />
QRegularExpressionMatch match = iter.next();<br />
if (match.isValid()) {<br />
qDebug() &lt;&lt; match.capturedTexts();<br />
}<br />
}<br />
@</p>
<p dir="auto">Produces this:<br />
@<br />
lower case QRegularExpression pattern "([\x61-\x7a]+)" true<br />
("the", "the")<br />
("cow", "cow")<br />
("over", "over")<br />
arabic regex "([\x600-\x6ff]+)" true<br />
("Yo", "Yo")<br />
("a", "a")<br />
("He", "He")<br />
("o", "o")<br />
("e", "e")<br />
@</p>
<p dir="auto">I think it might be a clue that if I specify the lowercase regex pattern as ([\x061-\x07a]+) it considers it to be invalid.</p>
<p dir="auto">By the way, QRegExp with the arabic pattern works Ok.</p>
<p dir="auto">Any ideas how to specify character classes correctly?</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/topic/47168/qregularexpression-with-a-character-class-behaving-strangely</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 19:36:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/47168.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Oct 2014 13:48:05 GMT</pubDate><ttl>60</ttl></channel></rss>