简体   繁体   English

regex_match仅用于长度

[英]regex_match for length only

I have this regex_match here 我这里有这个regex_match

regex_match[/^{0,100}+$/]

I am trying to just to validate the length of my string, but I get this error 我正在尝试仅验证我的字符串的长度,但出现此错误

A PHP Error was encountered
Severity: Warning

Message: preg_match(): Compilation failed: nothing to repeat at offset 7

Filename: libraries/Form_validation.php

Line Number: 911

What Am I doing wrong? 我究竟做错了什么?

although I'm admittedly unclear on what exactly you're trying to accomplish, why not just use strlen? 尽管我不确定您到底想完成什么,但是为什么不仅仅使用strlen?

strlen($string) >= 100 should give the same results. strlen($ string)> = 100应该给出相同的结果。

尝试这个:

regex_match[/^.{0,100}$/]

The {0,100} bit requires something to repeat, eg [az]{0,100} but your examples has nothing. {0,100}位需要重复一些内容,例如[az]{0,100}但是您的示例没有任何内容。 You might want ot use a . 您可能希望使用. for "any character" 对于“任何字符”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM