dimanche 19 avril 2015

PHP check if string contains maximum 30 letters/numbers in a sequence with preg_match

I'm stuck here and I can't find any results for my question, maybe because english is not my native language.


I want to match lines which contain maximum 30 letters/numbers in a sequence:


Is this even possible with preg_match?



preg_match("/[^A-Za-z0-9](max 30 in a sequence)/", $string)


Strings:



$string = "1234567890123456789012345678901234567890"; // FALSE
$string = "sdfihsgbfsadiousdghiug"; // TRUE
$string = "cfgvsdfsdf786sdf78s9d8g7stdg87stdg78tsd7g0tsd9g7t"; // FALSE
$string = "65656.sdfsdf.sdfsdf"; // TRUE
$string = "ewrwet_t876534875634875687te8---7r9w358wt3587tw3587"; // TRUE
$string = "sd879dtg87dftg87dftg87ftg87tfg087tfgtdf8g7tdf87gt8t___454"; // FALSE

Aucun commentaire:

Enregistrer un commentaire