且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何只匹配不包含点的字符串(使用正则表达式)

更新时间:2022-11-30 12:10:33

^[^.]*$

^[^.]+$

取决于您是否要匹配空字符串.某些应用程序可能会隐式提供 ^$,在这种情况下,它们是不必要的.例如:HTML5 input 元素的 pattern 属性.

Depending on whether you want to match empty string. Some applications may implicitly supply the ^ and $, in which case they'd be unnecessary. For example: the HTML5 input element's pattern attribute.

您可以在 regular-expressions.info 站点上找到更多重要信息.

You can find a lot more great information on the regular-expressions.info site.