Hi,

I'm trying to use a QRegExp as a quick way to find a value in a simple JSON string. Unfortunately I'm not so familiar with regular expressions and the examples I find on the internet don't seem to work with QRegExp.

I have a message like below and I want the 'dev' field :
{"dev":"RSNGSM32", "cmd":"setVoltage", "voltage":7.23}

I tried this :
Qt Code:
  1. QRegExp reFindName( "\"dev\":\"(.+?)\"" );
  2. if( reFindName.indexIn( sMessage ) >= 0 )
  3. {
  4. QString sEqName = reFindName.cap(0);
  5. qDebug() << "device name is" << sEqName;
  6. }
To copy to clipboard, switch view to plain text mode 

But it doesn't work. I read the documentation on QRegExp and fooled around with the expression, but got nothing that works.

Any advice would be appreciated.
Best regards,
Marc