Hien Nguyen
Hien Nguyen

Reputation: 21

QString QRegExp Remove Special Characters

I have a QString containing Latitude/Longitude data in the following format:

27° 34' 35.67" 45° 37' 28.34"

I want to be able to strip/remove all the special characters (°, ', ") but I am not able to do so with the following code:

lat.remove(QRegExp(QString::fromUtf8("[\\°\'\"]")));

When I printout the result of lat, I get:

lat = "27\260 34 35.67"

So it looks like it was able to strip the ' and " characters but not the ° symbol.

Any idea how to make this work? I would like the final format to contain only spaces or lat = "27 34 35.67"

Upvotes: 1

Views: 1461

Answers (1)

Hien Nguyen
Hien Nguyen

Reputation: 21

I was able to make it work with the following:

lat.remove(QRegExp(QString::fromUtf8("[\x00b0\'\"]")));

Upvotes: 1

Related Questions