\s*$
: This will match any (*
) whitespace (\s
) at the end ($
) of the text
^\s*
: This will match any (*
) whitespace (\s
) at the beginning (^
) of the text
\s
is a common metacharacter for several RegExp engines, and is meant to capture whitespace characters (spaces, newlines and tabs for example). Note: it probably won't capture all the unicode space characters. Check your engines documentation to be sure about this.