我有这个正则表达式:
^[a-zA-Z0-9]
我正在尝试选择除数字或字母之外的任何字符,但是当我测试时,只有第一个字符匹配。
当我使用以下正则表达式时:
[a-zA-Z0-9]
这些匹配项都是数字和字母,我需要对其取反,但^
无法起作用。
我有这个正则表达式:
^[a-zA-Z0-9]
我正在尝试选择除数字或字母之外的任何字符,但是当我测试时,只有第一个字符匹配。
当我使用以下正则表达式时:
[a-zA-Z0-9]
这些匹配项都是数字和字母,我需要对其取反,但^
无法起作用。
^
放在[a-zA-Z0-9]
内以实现所需的结果。 . Single character match except newline
"." Anything in quotations marks literally
A* Zero or more occurrences of A
A+ One or more occurrences of A
A? Zero or one occurrence of A
A/B Match A only if followed by B
() series of regexps grouped together
[] Match any character in brackets
[^] Do not match any character in brackets
[-] Define range of characters to match
^ Match beginning of new line
$ Match end of a line
{} Cardinality of pattern match set
\ Escapes meta-characters
| Disjunctive matches, or operation match
^
放在表达式开头表示“从字符串开头开始搜索”。您需要将其放在方括号内使其成为否定。[^a-zA-Z0-9]
^
放在括号内:[^a-zA-Z0-9]
^
must be inside character group to negate, e.g.[^a-zA-Z]
- marekful