[英]PHP Find text pattern
How can I find a 3 character text pattern in a string of: an upper or lowercase alphabetic character (a to z or A to Z) followed by a numeric character (0 to 9) followed by an upper or lowercase alphabetic character (a to z or A to Z) 如何在以下字符串中找到3个字符的文本模式:大写或小写字母字符(a到z或A到Z),后跟数字字符(0到9),然后是大写或小写字母字符(a到a) z或A到Z)
for example x4A or A3j or A7X or h1k 例如x4A或A3j或A7X或h1k
我认为你应该使用
/[a-zA-Z][0-9][a-zA-Z]/
$matches = array();
preg_match('/[a-z]\d[a-z]/i', $my_string, $matches);
// now $matches contains all you want
Try this: 尝试这个:
preg_match_all('/[A-Za-z]{1}[0-9]{1}[A-Za-z]{1}/',$string,$matches);
$matches
now contains all your matches. $matches
现在包含所有匹配项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.