compact Summary Removes all whitespace from the string. Signatures Click on a signature to select it and view its documentation. public string compact() public string compact(string replacement) public string compact(string replacement) public string compact(string() replacement) public string compact(string(string matched) replacement) public string compact(string(string matched) replacement) Usage public string compact() public string compact(string replacement) public string compact(string replacement) public string compact(string() replacement) public string compact(string(string matched) replacement) public string compact(string(string matched) replacement) Returns The string with all whitespace characters removed. The string with all whitespace characters replaced with the specified replacement. The string with all whitespace characters replaced with the specified replacement. The string with all whitespace characters replaced with the specified replacement. The string with all whitespace characters replaced with the specified replacement. The string with all whitespace characters replaced with the specified replacement. Parameters replacement The string to replace the whitespace with. Parameters replacement The string to replace the whitespace with. Parameters replacement A callback function that returns the string to replace the whitespace with. Parameters replacement A callback function that returns the string to replace the whitespace with. Parameters replacement A callback function that returns the string to replace the whitespace with. Description Removes all whitespace (globally) from the string. Replaces all contiguous whitespace (globally) in the string with the specified replacement string. Replaces all whitespace (globally) in the string with the specified replacement string, with the option to specify if whitespace should be matched contiguously. Replaces all contiguous whitespace (globally) in the string with the specified replacement string (defined with the replacement callback function). Replaces all contiguous whitespace (globally) in the string with the specified replacement string (defined with the replacement callback function). Replaces all whitespace (globally) in the string with the specified replacement string (defined with the replacement callback function), with the option to specify if whitespace should be matched contiguously. Examples Basic Usage 123import System; Console.log("foo bar".compact()); // "foobar" Basic Usage 123import System; Console.log("foo bar".compact("<br>")); // "foo<br>bar" Basic Usage 1234import System; Console.log("foo bar".compact("<br>", true)); // "foo<br>bar"Console.log("foo bar".compact("<br>", false)); // "foo<br><br>bar" Basic Usage 123import System; Console.log("foo bar".compact(string() { return "<br>"; })); // "foo<br>bar" Basic Usage 123import System; Console.log("foo bar".compact(string(string matched) { return "|" + matched + "|"; })); // "foo| |bar" Basic Usage 1234import System; Console.log("foo bar".compact(string(string matched) { return "|" + matched + "|"; }), true)); // "foo| |bar"Console.log("foo bar".compact(string(string matched) { return "|" + matched + "|"; }), false)); // "foo| || |bar" Share HTML | BBCode | Direct Link