C++/CLI Code Snippet - Remove White Spaces

C++/CLI Code Snippet - Remove White Spaces

C++/CLI Code Snippet - Remove White Spaces

C++/CLI code snippet to remove all white spaces from a string. TrimWhiteSpace strip all white spaces from a given.

Bookmark:

C++/CLI Code Snippet - Remove White Spaces

This .Net C++/CLI code snippet removes all white spaces from a string. White spaces removing done by set of successful matches found by iteratively applying a regular expression pattern to the input string.

System::String ^TrimWhiteSpace(System::String ^str)
{
    return System::Text::RegularExpressions::Regex::Replace(str, "^\\s+", System::String::Empty);
}


C++/CLI Keywords Used:

  • Regex
  • Replace

Code Snippet Information:

  • Applies To: .Net, C++, CLI, HTML, Regular Expression
  • Programming Language : C++/CLI

External Resources:

Leave a comment