正则表达式的含义是什么?

0 regex

任何人都可以指出它吗?

  1. /^([a-zA-Z]+)/
  2. /\d|M|H/
  3. RegExp.$1

Bar*_*ers 5

1.

/^([a-zA-Z]+)/

^             # match the start of the input string
(             # start capture group 1
  [a-zA-Z]+   #   match one or more from the set {a..z,A..Z} 
)             # end capture group 1
Run Code Online (Sandbox Code Playgroud)

2.

/\d|M|H/

\d  # match a digit: {0..9}
|   # OR
M   # match the literal 'M'
|   # OR
H   # match the literal 'H'
Run Code Online (Sandbox Code Playgroud)

正如@Tim在评论中所建议的那样,最好写成: [\dMH]

3.

RegExp.$1可能不是正则表达式(至少,它不能匹配任何东西).它可能是一种语言结构.