Symbol for any number of any characters in regex?

前端 未结 5 1373
南笙
南笙 2020-11-29 21:21

I\'m wondering is there a symbol for any number (including zero) of any characters

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 21:43

    You can use this regular expression (any whitespace or any non-whitespace) as many times as possible down to and including 0.

    [\s\S]*
    

    This expression will match as few as possible, but as many as necessary for the rest of the expression.

    [\s\S]*?
    

    For example, in this regex [\s\S]*?B will match aB in aBaaaaB. But in this regex [\s\S]*B will match aBaaaaB in aBaaaaB.

提交回复
热议问题