以下^.*$ regexp匹配什么?

use*_*829 3 java regex validation

有人可以解释以下正则表达式匹配的内容吗?

^.*$
Run Code Online (Sandbox Code Playgroud)

谢谢!

Luk*_*keH 21

要么整个字符串或者整条线,这取决于是否多行模式被使用.


dav*_*ave 15

一切.

^ is the beginning of the string. 
. is any character. 
* means 0 or more of said characters. 
$ is the end of the string. 
Run Code Online (Sandbox Code Playgroud)

所以这个正则表达式匹配0或更多字符开始和结束一个字符串(这是一切).

  • 默认情况下,大多数正则表达式实现都不匹配DOT元字符的`\ r`和`\n`.所以,不是"一切". (3认同)