Home >Backend Development >PHP Tutorial >利用正则表达式判断输入格式的问题

利用正则表达式判断输入格式的问题

WBOY
WBOYOriginal
2016-06-20 12:32:07875browse

试了很多次都没用,输入一串字符,利用正则表达式判断是否满足start1:1-1000这个格式,设定的正则表达式是什么样的啊?(说明,start(这边是字母或者数字):(任意数字)-(任意数字)这个格式的正则表达式)


回复讨论(解决方案)

$str = 'start1:1-1000';$res = preg_match('/^start[a-zA-Z0-9]:\d+-\d+$/', $str, $match);

start\w+:\d+-\d+

你是指这个意思?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn