0

How can i match text that is 10 characters at minimum and 4000 at maximum and that text can be any character. Furthermore i need to accept space tab carriage return and new lines.

I tried:

"/.{10,4000}$/"

But that didn't work! I think that the dot does not include carriage return for example.

So can anybody help me with this ?

Sorry any misspelling, i am Portuguese.

PhearOfRayne
  • 4,990
  • 3
  • 31
  • 44
Fábio Linhares
  • 107
  • 1
  • 14

3 Answers3

6

Note that the dot will match any character. So why not just do this:

if(strlen($text) >= 10 && strlen($text) <= 4000) {
    echo "match!";
}
jszobody
  • 28,495
  • 6
  • 61
  • 72
3

s so . matches newlines.

"/^.{10,4000}$/s"
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
1

try this pattern /^.{10,4000}$/s note the "s" modifier and the anchor "^"

alpha bravo
  • 7,838
  • 1
  • 19
  • 23
  • @John Doyle, thanks for your comment, I believe my answer matches the accepted answer by the OP. the accepted answer just happened to be posted while I was editing mine. – alpha bravo Dec 03 '13 at 20:35