Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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
.NET正则表达式转换为PHP-发行抢手美元金额_Php_Regex - Fatal编程技术网

.NET正则表达式转换为PHP-发行抢手美元金额

.NET正则表达式转换为PHP-发行抢手美元金额,php,regex,Php,Regex,我对PHP不太熟悉,从一系列文本中抓取一美元金额有点困难 全文如下: Shipment price $11 Regular shipment Shipment price $15 Express shipment 在.net中,我将使用以下正则表达式: (?<=\$).*(?=Regular) 哪个输出:11 我只是想得到正常装运的价格,没有美元符号。有没有人能告诉我如何用php实现这一点 非常感谢 它在php中也类似,但是您应该使用它 (?<=\$)\S+(?=\s*Regu

我对PHP不太熟悉,从一系列文本中抓取一美元金额有点困难

全文如下:

Shipment price $11 Regular shipment
Shipment price $15 Express shipment 
在.net中,我将使用以下正则表达式:

(?<=\$).*(?=Regular)
哪个输出:11 我只是想得到正常装运的价格,没有美元符号。有没有人能告诉我如何用php实现这一点

非常感谢

它在php中也类似,但是您应该使用它

(?<=\$)\S+(?=\s*Regular)
见演示

$re = "/(?<=\\$)\\S+(?=\\s*Regular)/i"; 
$str = "Shipment price \$11 Regular shipment\nShipment price \$15 Express shipment "; 

preg_match_all($re, $str, $matches);