简体   繁体   English

Preg_match与正则表达式?

[英]Preg_match with regular expressions?

Im trying to catch a posted variable with name that begins with 'price' and ends with a number 0-9 and save the number in a variable $matches . 我试图捕获一个以'price'开头并以数字0-9结束的名称的已发布变量,并将该数字保存在变量$matches For some reason, the code i have isnt catching it, so obviously my syntax is off. 由于某种原因,我没有捕获代码,因此显然我的语法不正确。 Heres my code.. 这是我的代码。

elseif (preg_match('price/[1-9]/', $field_name, $matches)) {
preg_match('/^price([0-9])$/', $field_name, $matches)

$matches[1]将为您提供数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM