我想检查一个输入字符串来验证一个正确的文本。
a.我希望用户允许书写字母数字字符,包括句点、逗号、连字符和圆括号()
b.但是,我不希望用户一起输入3位或3位以上数字的数字。例如:12是允许的,而185是不允许的。
c.我不希望用户输入诸如“…………..”、“----------------”、“aaaaaaaaaa”或“bbbbbbbb”等字符串。
请建议使用相同的正则表达式。
我想检查一个输入字符串来验证一个正确的文本。
a.我希望用户允许书写字母数字字符,包括句点、逗号、连字符和圆括号()
b.但是,我不希望用户一起输入3位或3位以上数字的数字。例如:12是允许的,而185是不允许的。
c.我不希望用户输入诸如“…………..”、“----------------”、“aaaaaaaaaa”或“bbbbbbbb”等字符串。
请建议使用相同的正则表达式。
您可以使用正则表达式:
(?!.*(.)1{2})^[a-zA-Z0-9.,()-]*$
它使用负前瞻(?!.*(.)1{2})
来确保任何字符不存在3个重复的组。
然后,它使用正则表达式^[a-zA-Z0-9.,()-]*$
来确保字符串仅由字母、数字、句点、逗号、括号和连字符组成。
Most regex libs support the folloing:
/(.)1{2,}/
其中1
是反向引用
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...