当我使用preg_match_all(“#BT(。*)ET#ismU”,,)从下面的martix中提取名称。我无法读取namePETER NIBIN CHERUPARAMBIL
Tj ET q 2950 3380 2142 221 re W n BT 1 0 0 -1 2950 3545 Tm 0 0 0 sc /a 143 Tf (PETER NIBIN) Tj ET Q BT 1 0 0 -1 975 3525 Tm 0 0 0 sc /a 143 Tf (555555555) Tj 8000 0 Td 0 0.502 0.251 sc (Entered to Country) Tj -1785 0 Td 0 0 0 sc (03-04-2014) Tj -4240 -379 Td (ALVIN JOY JOY) Tj -1975 20 Td (666666) Tj 8000 0 Td 0 0.502 0.251 sc (Entered to Country) Tj -1785 0 Td 0 0 0 sc (03-04-2014) Tj -4240 -379 Td (TONY KAIPPALLY DANIEL) .
如何从上述矩阵中读取PETER NIBIN CHERUPARAMBIL的名称?
答案 0 :(得分:0)
您可以尝试使用以下正则表达式:
/\(([A-Z ]+)\)/
<?php
$str='Tj ET q 2950 3380 2142 221 re W n BT 1 0 0 -1 2950 3545 Tm 0 0 0 sc /a 143 Tf (PETER NIBIN) Tj ET Q BT 1 0 0 -1 975 3525 Tm 0 0 0 sc /a 143 Tf (555555555) Tj 8000 0 Td 0 0.502 0.251 sc (Entered to Country) Tj -1785 0 Td 0 0 0 sc (03-04-2014) Tj -4240 -379 Td (ALVIN JOY JOY) Tj -1975 20 Td (666666) Tj 8000 0 Td 0 0.502 0.251 sc (Entered to Country) Tj -1785 0 Td 0 0 0 sc (03-04-2014) Tj -4240 -379 Td (TONY KAIPPALLY DANIEL) .';
preg_match_all('/\(([A-Z ]+)\)/', $str, $matches);
print_r($matches[1]);
它将在括号之间匹配大写文本(带空格的字母),因此它将匹配:
PETER NIBIN
ALVIN JOY JOY
TONY KAIPPALLY DANIEL