I want to remove beginning and ending spaces from a string, like the function trim() in PHP. I want to do this with a regexp. In PHP I’d do this:
$str = " a s d ";
$mytrim = preg_match_all("#^\s*([^\s].*)\s*$#U", $str, $mas);
echo $mas[1][0];
I don’t know how to do this because in Javscript regex, this is not true: “all except asked symbols – [^some symbols]“. I can do this with two regexes but I’m interested how I can do it with one?
From the first google result of “javascript trim”: