Detecting punctuation marks in QString variables

Hi everyone,

Does anyone know how to remove punctuation marks from a QString variable ? I have cheked the doc but have not found anything. I'm looking at something specific like ispunct function. Maybe I'm missing something though. I would like to avoid converting my QString to string if possible. Thanks.
https://doc.qt.io/qt-5/qstring.html
https://doc.qt.io/qt-5/qchar.html

QString.at(i) returns a QChar.

QChars have a member function called isPunct().

There's also isLetterOrNumber()
https://doc.qt.io/qt-5/qchar.html#isLetterOrNumber

Edit: One more option is to use the QString.remove function, and give it a regular expression.
https://doc.qt.io/qt-5/qstring.html#remove-4
Last edited on
As a PS to the above suggestion, there are other forms of remove() that might be easier to use here.
Topic archived. No new replies allowed.