开发者

Symbol for any number of any characters in regex?

开发者 https://www.devze.com 2023-03-14 12:41 出处:网络
I\'m wondering is开发者_Python百科 there a symbol for any number (including zero) of any characters.*

I'm wondering is开发者_Python百科 there a symbol for any number (including zero) of any characters


.*

. is any char, * means repeated zero or more times.


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.


Do you mean

.*

. any character, except newline character, with dotall mode it includes also the newline characters

* any amount of the preceding expression, including 0 times


I would use .*. . matches any character, * signifies 0 or more occurrences. You might need a DOTALL switch to the regex to capture new lines with ..


Yes, there is one, it's the asterisk: *

a* // looks for 0 or more instances of "a"

This should be covered in any Java regex tutorial or documentation that you look up.

0

精彩评论

暂无评论...
验证码 换一张
取 消