Qt remove whitespace characters in QString

1. Two functions in QString
1.QString QString::simplified() const
Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.
Returns a string with whitespace removed from the beginning to the end, and the whitespace inside each sequence replaced with a single space (both the beginning and the end are removed)
for example:
 QString str = "  lots\t of\nwhitespace\r\n ";
 str = str.simplified();
 // str == "lots of whitespace";
'\t', '\n', '\v', '\f', '\r', ' ' are all whitespace processing.

2.QString QString::trimmed() const
Returns a string that has whitespace removed from the start and the end.
Returns a string with whitespace removed from the beginning to the end. Also remove leading and trailing whitespace
for example:
QString str = "  lots\t of\nwhitespace\r\n ";
 str = str.trimmed();
 // str == "lots\t of\nwhitespace"
It is hereby recorded!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325725215&siteId=291194637