The forward slashes at both end is the regex equivalent of " or ' for strings - they indicate the beginning and end of the regex expression. Also, in regex, after the last forward slash you can put certain 'flags' - g for global, i for case-insensitive, m for multi-line.
So, as an example, if you wanted to write a function that will trim whitespace from the beginning AND end of a string, you could do:
The first forward slash indicates beginning of the regex expression.
^ means "from the beginning of the string"
\s is whitespace (space, tab, carriage return, newline).
+ means "one or more of the previous character".
| means "or".
$ means "at the end of the string".
The last forward slash indicates end of the expression.
g is "global".
The global flag is important, because without it the regex engine would remove only the first encountered instance of whitespace. If there are two spaces at the beginning and end of the string, without the global flag the engine would only replace the first two spaces and ignore the last two. The global flag says, "Hey, if you find spaces at the END of the string, replace those with blanks, too."