#includewxString str = " Foo"; str = str.Strip(wxString::both); // Removes whitespace from both beginning and end of the string wxPrintf("%s\n", str); // Output: "Foo"
#includewxString str = "Bar "; str = str.Strip(wxString::trailing); // Removes whitespace from the end of the string wxPrintf("%s\n", str); // Output: "Bar"
#includePackage library: wxWidgets#include wxString str = " Baz "; wxRegEx rx("\\s+", wxRE_ADVANCED); // Regular expression that matches one or more whitespace characters int start, end; if (rx.Matches(str)) { rx.GetMatch(&start, &end, 0); // Get the start and end indexes of the first match str = str.Mid(start, end - start); // Extract the match from the original string } wxPrintf("%s\n", str); // Output: "Baz"