我想从字符串里抓出房间号,具体格式为以#开始,逗号或者空格结束
但是PHP的preg_match给出的结果比perl的多了一个逗号,请问为什么以及怎么解决
,谢谢
php:
preg_match('/(#.*?)[ ,]/','112 east coast road #b1-15, 112 katong, singapore 428802', $match);
if($match) {
echo "match=".$match[0];
}
else {
echo 'not match';
}
output: match=#b1-15,
perl:
use strict;
my $str = "112 east coast road #b1-15, 112 katong, singapore 428802";
if($str =~ /(#.*?)[ ,]/) {
print "match = $1";
}
else {
print "not match";
}
output: match=#b1-15
--
FROM 220.255.242.*