JS regular expression (learning note 2) matching URL parameter

Time:2021-4-15
. Matches any character except the newline character
\w Match letters, numbers, underscores, Chinese characters
\s Match any white space
\d Match number
^ Start position of matching character
$ End position of matching character
* Repeat zero or more times
+ Repeat one or more times
? Repeat zero or one time
{n} Repeat n times
{n,} Repeat n times or more
{n,m} Repeat n or m times

The problem of URL parameter matching


[Ctrl + a all optional note: to introduce external JS, you need to refresh the page again]

In fact, you can also use the array method to match, which is a little more troublesome

If you have a better way. You can leave a message.