gpt4 book ai didi

javascript - 需要有关 Javascript 正则表达式的帮助

转载 作者:行者123 更新时间:2023-11-28 16:33:41 25 4
gpt4 key购买 nike

该框应允许:

  • 大小写字母(不区分大小写)
  • 数字 0 到 9
  • Angular 色,! # $ % & ' * + -/= ? ^ _ ` { | } ~
  • 字符“.”前提是它不是第一个或最后一个字符

最佳答案

尝试

^(?!\.)(?!.*\.$)[\w.!#$%&'*+\/=?^`{|}~-]*$

说明:

^         # Anchor the match at the start of the string
(?!\.) # Assert that the first characters isn't a dot
(?!.*\.$) # Assert that the last characters isn't a dot
[\w.!#$%&'*+\/=?^`{|}~-]* # Match any number of allowed characters
$ # Anchor the match at the end of the string

关于javascript - 需要有关 Javascript 正则表达式的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4848623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com