Matches leading and trailing whitespace to trim it.
/^\s+|\s+$/gconst regex = /^\s+|\s+$/g;
' test '.replace(regex, '');import re
regex = re.compile(r'^\s+|\s+$')
clean = regex.sub('', ' test ')import "regexp"
re := regexp.MustCompile(`^\s+|\s+$`)
clean := re.ReplaceAllString(` test `, "")use regex::Regex;
let re = Regex::new(r"^\s+|\s+$").unwrap();
let clean = re.replace_all(" test ", "");