web123456

vue regular verification

Create regular expressions through new
var  qq = 
Created by literal
var qq =/ Write casually /

var reg = / abc /
As long as the string contains "abc" in it, it is a regular expression /abc /

var reg = / [a-z A-Z 0-9-_*&^%$#@] /
Symbols can be added

Verify the regular content: .test()
There is a return value, return true, false


Indicates who to start:^
var reg = /^abc /  Verify that the string starts with "abc"
Indicates who ends with: $
var reg = /abc$ /  Verify whether the string ends with "abc"

*    Repeat 0 or more times
+    Repeat 1 or more times
? Repeat 0 or 1 time
{n}    Repeat n times
{n,}    Repeat n times or more
{n, m}    Repeat n times to m times


Braces  quantitle       In it indicates the number of times you can repeat  { }
Brackets Character collections Match any character in square brackets [ ]
Brackets indicate priority  ( )


\d    Match any number between 0-9, equivalent to [0-9]
\D    Match all characters other than 0-9, equivalent to [^0-9]
\w    Match any letters, numbers and underscores, equivalent to [A-Za-z0-9]
\W    The characters except all letters, numbers and underscores are equivalent to [^A-Za-z0-9_ ]
\s   Match spaces (including line breaks, tabs, space characters, etc.), which is equivalent to [ \t\r\n\v\f ]
\S    Match characters that are not spaced, equivalent to [ ^\t\r\n\v\f ]


Replace content: replace (regular, content to be replaced)
replace(/a/ig) g isglobalGlobal meaning: / a / i is case-insensitive