Can anybody point it out?
/^([a-zA-Z]+)/
/\d|M|H/
RegExp.$1
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
2.
/\d|M|H/
\d # match a digit: {0..9}
| # OR
M # match the literal 'M'
| # OR
H # match the literal 'H'
which, as @Tim suggested in the comments, could better be written as: [\dMH]
3.
RegExp.$1
is probably not a regex (at least, it can't match anything). It's likely a language construct.
That means:
- /^([a-zA-Z]+)/ - it must starts with any alphabet
- /\d|M|H/ - it can be any digits, M or H
- RegExp.$1 - First argument of the Regex
精彩评论