How to match “any character” in regular expression?

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

The following should be matched:

AAA123
ABCDEFGH123
XXXX123

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

11条回答
  •  孤城傲影
    2020-11-27 10:19

    The most common way I have seen to encode this is with a character class whose members form a partition of the set of all possible characters.

    Usually people write that as [\s\S] (whitespace or non-whitespace), though [\w\W], [\d\D], etc. would all work.

提交回复
热议问题