Parsing strings with QT



  • Is there any simple and elegant way to parse strings like this:

    0R1,Dn=090D,Dm=116D,Dx=167D,Sn=0.0M,Sm=0.0M,Sx=0.1M
    0R2,Ta=23.4C,Ua=46.9P,Pa=996.0H
    0R3,Rc=0.00M,Rd=0s,Ri=0.0M,Hc=0.0M,Hd=0s,Hi=0.0M
    0R5,Th=23.9C,Vh=0.0N,Vs=24.3V,Vr=3.494V

    in QT? The line consists from command, then comma and after then field names with equations separated by commas.


  • Lifetime Qt Champion

    Hi,

    Depends on what you want to get from your parsing. e.g.

    @QStringList elementList = myString.split(',');@

    and you have a list containing each element.

    You can also use regular expressions with QRegularExpression or QRegExp if you're on Qt 4

    Hope it helps


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.