如何避免在字段中使用特殊字符... [英] How Do I Avoid Special Characters In A Field...
问题描述
如何防止在字段中输入特殊字符。
i tryed:
NOT (REGEX(电话,
\\ D *?(\\\\\\ D *?)))
但是我不能在空间放空间。
有人可以帮我吗?
谢谢
#regards
Seb。
你可以使用这个正则表达式:
/ [\ w] + /
这将允许单词字符和空格。
此任务的通用正则表达式模式不存在。这是原因 [ ^ ]。
看看这里: http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7 [ ^ ]并为您选择合适的。
\ D表示任何不是数字的字符,\ d表示任何字符都是数字,所以你的正则表达式是:
任何不是数字的字符,任意数量的重复,尽可能少的
编号的捕获组。 [\\\\ D *?]
\\\\ D *?
任意数字
任何不是数字的字符,任意数量的重复,尽可能少
这对于手机来说有点奇怪数字,这是你似乎想要匹配的 - 因为它将匹配任何有数字的东西...
正常电话号码正则表达式是这样的:
\((?< areacode> \d {3})\)\ * *(?< number> \d {3}( ?: - | \ * *)\d {4})< / number>< / areacode>
这可能值得你从那里开始弄清楚如何准确匹配你的目标。
为了帮助你,请获取 Expresso [ ^ ] - 它是免费的,它检查并生成正则表达式。
这是我得到你的正则表达式的解释,以及样本电话号码fr OM
Hi,
How do i prevent typing special characters in a field.
i tryed:
NOT(REGEX(Phone,
"\\D*?(\\d\\D*?)"))
but then i cant put spaces in space should be allowed.
can anybody help me please?
Thank you
#regards
Seb.
You can use this regex:
/[\w ]+/
This will allow word characters and spaces.
A universal regex pattern for this task does not exists. It's set of reason[^].
Have a look here: http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7[^] and choose the proper one for you.
"\D" means "any character that isn't a digit", and "\d" means "any character that is a digit" so your regex is:
Any character that is not a digit, any number of repetitions, as few as possible A numbered capture group. [\d\D*?] \d\D*? Any digit Any character that is not a digit, any number of repetitions, as few as possible
Which is a little odd for a phone number, which is what you appear to be trying to match - because it will match anything that has a digit in it...
The "normal" phone number regex is along the lines of:
\((?<areacode>\d{3})\)\s*(?<number>\d{3}(?:-|\s*)\d{4})</number></areacode>
And it might be worth your starting there and working out how to match exactly what you are after.
To help you in this, get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
It's where I got the explanation of your regex, and the sample phone number one from.
这篇关于如何避免在字段中使用特殊字符...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!