How to match “any character” in regular expression?

前端 未结 11 649
忘了有多久
忘了有多久 2020-11-27 09:23

The following should be matched:

AAA123
ABCDEFGH123
XXXX123

can I do: \".*123\" ?

11条回答
  •  迷失自我
    2020-11-27 10:18

    [^] should match any character, including newline. [^CHARS] matches all characters except for those in CHARS. If CHARS is empty, it matches all characters.

    JavaScript example:

    /a[^]*Z/.test("abcxyz \0\r\n\t012789ABCXYZ") // Returns ‘true’.
    

提交回复
热议问题