Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何按字符拆分字符串并按正则表达式检查格式_Php_Regex_Laravel - Fatal编程技术网

Php 如何按字符拆分字符串并按正则表达式检查格式

Php 如何按字符拆分字符串并按正则表达式检查格式,php,regex,laravel,Php,Regex,Laravel,我知道Laravel支持使用下面的正则表达式进行路由 Route::get('user/{id}', function($id) { // }) ->where('id', '[0-9]+'); 如果我的端点像/{size}/photo,例如/100x100/foo.jpg 如何使用正则表达式检查大小是否有效 我对regex不熟悉。谢谢Route::get({size}/{filename}.jpg',函数($size,$filename){ 列表($width,$height)

我知道Laravel支持使用下面的正则表达式进行路由

Route::get('user/{id}', function($id) {
    //
})
->where('id', '[0-9]+');
如果我的端点像/{size}/photo,例如/100x100/foo.jpg 如何使用正则表达式检查大小是否有效

我对regex不熟悉。谢谢

Route::get({size}/{filename}.jpg',函数($size,$filename){
列表($width,$height)=分解($x',$size);
//现在使用$width和$height,享受生活吧!
})
->其中('size','\d+x\d+');
Route::get({size}/{filename}.jpg',函数($size,$filename){
列表($width,$height)=分解($x',$size);
//现在使用$width和$height,享受生活吧!
})
->其中('size','\d+x\d+');

/
上分解以获得大小,然后在
x
上分解以获得值?在
/
上分解以获得大小,然后在
x
上分解以获得值?我是否需要更多信息?有什么建议可以把零也过滤掉吗?
[1-9]\d*+x[1-9]\d*
也许这样吧?我可以问更多的问题吗?有什么建议可以把零也过滤掉吗?
[1-9]\d*+x[1-9]\d*
也许这样?