![](/img/trans.png)
[英]Regex that will only allow alphanumeric characters and underscore and specific placeholder inside curly braces
[英]Regex only allow alphanumeric and at least two characters
我正在使用PHP,並且需要驗證的字符串必須是...
我有我認為僅適用於Az和0-9的正確正則表達式是...
if(preg_match('/[^a-z_\-0-9]/i', $string))
{
echo "not valid string";
}
但是我該如何添加以確保它至少兩個字符長?
我會看
^[a-zA-Z0-9]{2,}$
start string, any character in a-z or A-Z or 0-9, matched two or more times, end string.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.