需要.net正则表达式来阻止所有空格和@字符(Need a .net regex to block all spaces and the @ character)

编程入门 行业动态 更新时间:2024-10-26 18:29:07
需要.net正则表达式来阻止所有空格和@字符(Need a .net regex to block all spaces and the @ character)

我有.net表达式来阻止空格,但不知道如何修改它以阻止@字符。

当前表达式来阻止空格: ^\s*\S+\s*$

I have the .net expression to block spaces but no idea how to modify it to also block the @ character.

Current expression to block spaces: ^\s*\S+\s*$

最满意答案

通过使用^ inside [ ]来阻止你不想匹配的内容:

^[^\s@]+$

演示

By using ^ inside [ ] to block what you don't want to be matched :

^[^\s@]+$

demo

更多推荐

本文发布于:2023-08-07 19:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空格   字符   正则表达式   net   character

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!