Pike v8.1 release 6

Method String.normalize_space()


Method normalize_space

string normalize_space(string s, string|void whitespace)

Parameter s

Is returned after white space in it has been normalised. White space is normalised by stripping leading and trailing white space and replacing sequences of white space characters with a single space.

Parameter whitespace

Defines what is considered to be white space eligible for normalisation. It has a default value that starts with " \t\r\n\v\f" and in addition to that contains all whitespace characters part of Unicode. The first character denotes the character for replacing whitespace sequences.

Note

Trailing and leading whitespace around \r and \n characters is stripped as well (only useful if they're not in the whitespace set).

Note

This function is a lot faster with just one argument (i.e. the builtin whitespace set has an optimised code path).