正则表达式 - 来自[abcd] abcd efhg(abcd)的3个数据

时间:2017-04-21 13:05:50

标签: php regex string preg-match

我有字符串:

[18d03] Complete screen 12" (tablet)

我想得到:

$one = '18d03';
$two = 'Complete screen 12"';
$three = 'tablet';

现在我做到了:

preg_match('/^(.+?)\s*\(([^)]+)\)$/', $local->parts_name, $explode);

但是这个正则表达式首先看不到18d03

1 个答案:

答案 0 :(得分:1)

有几种方法可以做到这一点,但/^\[(.+)\] (.+?) \((.+)\)$/应该做你想要的。具有特殊含义的\ s esape字符。

您可以在http://regexr.com/3fq01

预览
相关问题