Demonstrates String Trimming in Javascript

This uses Javascript Regular Expressions to strip out extra white space surrounding the given string. In this case, we are using the special regular expression (reg exp) character "\s" which stands for white space characters. "\s" will match space, tab, vertical tab, horizontal tab, line feed, line returns, and new line characters. In the Javascript code, you will notice that it is "\\s". That is because the "\" is itself a special character within Javascript and must be escaped for the regular expression.

Enter your text in the box below and then select your desired type of trimming to see the resultant string.

Text:


Result: