Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用这种模式来限制用户只使用最多 5 位小数的数字,但它只有在用户输入 ' , ' 作为小数点时才有效,但我想让用户可以插入 ' 。' 同样,代码:
ng-pattern="/^[0-9]+(\.[0-9]{1,5})?$/"
我想知道这是否是某种语言环境问题 - 它使用逗号作为小数,而不是停止。
对我来说,该模式按预期工作(例如“6.7”=有效)
你想要的是括号和管道。像这样:“(.|,)” 这表示此处可以使用句点或逗号。
http://regexr.com/3da8k