<?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[Read data from double quotes txt file.]]></title><description><![CDATA[<p dir="auto">Hi Guys, can someone help me?</p>
<p dir="auto">I would like to read a TXT file and extract some data that are in double quotes. I managed to make the code by reading other forums. It works for the first data found. I would like to continue finding for another data on the same line.</p>
<p dir="auto">//Here is the TXT file content:</p>
<p dir="auto">sd sdkfjsld lksjdfls pon. 234234; sd;flksd "74.4" lkasjdlsk aslfksjdfls	sdlkfjsldf	sldkfjsld 342352 ds;flsdkf "256"	"sdlkfjds<br />
2873ihwefisjhfs dlkfjlsd fgdf090324i2. 43p530i953kldf,msd ;	lsdjkflskfn	fdlsmkfsd	"8" ..,lmsdlifjodsf sokdjflsdn 	<br />
0.01				<br />
0.02				<br />
0.03				<br />
0.04</p>
<p dir="auto">//The code:</p>
<p dir="auto">void MainWindow::Convert () {</p>
<pre><code>QString filter = "All file (*.txt);; Text file (*.txt)";
QString file_name = QFileDialog::getOpenFileName(this, "Upload file",QDir::homePath(), filter);
QFile file (file_name);

const QRegularExpression regex("\"([A-Za-z0-9_\\./\\-\\s]*)\"");

if(file.open(QFile::ReadOnly | QFile::Text)){
    QTextStream in(&amp;file);

     qDebug() &lt;&lt; "Opened file:" &lt;&lt; file;

    while(!in.atEnd()){
        const QString lineString = in.readLine(); // read line

        qDebug() &lt;&lt; "LineString" &lt;&lt; lineString;

        const QRegularExpressionMatch match = regex.match(lineString); // apply the pattern on Text

        if(match.hasMatch()){ // if captured the words
            qDebug() &lt;&lt; "Full Capture: " &lt;&lt; match.captured(0);
            qDebug() &lt;&lt; "Captured Words: " &lt;&lt; match.captured(1) &lt;&lt; match.captured(2) &lt;&lt; match.captured(3) &lt;&lt; match.captured(4);
        }
    }
    file.close();
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">//Output:<br />
Opened file: QFileInfo(/Users/../Desktop/Tests.txt)<br />
LineString "sd sdkfjsld lksjdfls pon. 234234; sd;flksd "74.4" lkasjdlsk\taslfksjdfls\tsdlkfjsldf\tsldkfjsld 342352 ds;flsdkf "256"\t"sdlkfjds"<br />
Full Capture:  ""74.4""<br />
Captured Words:  "74.4" "" "" ""<br />
LineString "2873ihwefisjhfs dlkfjlsd fgdf090324i2. 43p530i953kldf,msd ;\tlsdjkflskfn\tfdlsmkfsd\t"8" ..,lmsdlifjodsf sokdjflsdn \t"<br />
Full Capture:  ""8""<br />
Captured Words:  "8" "" "" ""<br />
LineString "0.01\t\t\t\t"<br />
LineString "0.02\t\t\t\t"<br />
LineString "0.03\t\t\t\t"<br />
LineString "0.04\t\t\t\t"</p>
<p dir="auto">Thank you very much</p>
]]></description><link>https://forum.qt.io/topic/126845/read-data-from-double-quotes-txt-file</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 00:23:57 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/126845.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 May 2021 20:00:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Read data from double quotes txt file. on Fri, 21 May 2021 02:12:51 GMT]]></title><description><![CDATA[<p dir="auto">Solved:</p>
<pre><code>        QRegularExpressionMatchIterator i = regex.globalMatch(lineString);

        while (i.hasNext()) {
            QRegularExpressionMatch match = i.next();
            if (match.hasMatch()) {
                 qDebug().noquote() &lt;&lt;"Value"&lt;&lt; match.captured(0);
</code></pre>
<p dir="auto">}</p>
]]></description><link>https://forum.qt.io/post/660798</link><guid isPermaLink="true">https://forum.qt.io/post/660798</guid><dc:creator><![CDATA[pedromenezes]]></dc:creator><pubDate>Fri, 21 May 2021 02:12:51 GMT</pubDate></item></channel></rss>