Regular expression that will isolate numbers and text.

Qt Code:
  1. QStringList linesInt;
  2. QRegExp rx("(\\d+)");
  3. QString text = "5001 1001 5002 1002.5 Observation reason: 10 river and pond."
  4.  
  5. int pos = 0;
  6. while ((pos = rx.indexIn(text,pos)) != -1){
  7. linesInt << rx.cap(1);
  8. pos += rx.matchedLength();
  9. }
  10. //linesInt = (5001, 1001, 5002, 1002, 5, 10) --- I want linesInt = (5001, 1001, 5002, 1002.5)
  11. //or linesInt = (5001, 1001, 5002, 1002.5, Observation reason: 10 river and pond.)
To copy to clipboard, switch view to plain text mode 

The code below give me the result I expect. But I would have to test if the first 4 are numbers.

Qt Code:
  1. QStringList linesInt;
  2. QRegExp rx("\t");
  3. QString text = "5001\t1001\t5002\t1002.5\tObservation reason: 10 river and pond."
  4. linesInt = text.split(rx,QString::SkipEmptyParts);
  5. //linesInt = (5001, 1001, 5002, 1002.5, Observation reason: 10 river and pond.)
To copy to clipboard, switch view to plain text mode 

Someone would indicate a QRegExp?