PDA

View Full Version : Token in QString



Imhotep
6th November 2020, 19:06
Let


this.is.a.string

a QString. Is there a QString method that returns me the nth token based on a separator character? Something in the form


method(QString,1,46) return "this"

The separator character in this case is the dot

ChrisW67
6th November 2020, 22:51
Is there a QString method that returns me the nth token based on a separator character?

Yes, QString::section() (https://doc.qt.io/qt-5/qstring.html#section).

d_stranz
8th November 2020, 22:09
Or QString::split(), using '.' as the split delimiter if you want all of the pieces.