<?php
$sourcestring='part "C28"
{ type : "1AB010050093",
%cadtype : "1AB010050094",
shapeid : "2_1206",
descr : "4700.0000 pFarad 10.00 % 100.0 - VE5-VS3",
insclass : "CP6A,CP6B",
gentype : "RECT_032_016_006",
machine : "SMT",
%package : "080450E",
%_item_number: "508",
%_Term_Seq : "" }
part "C29"
{ type : "1AB008140029",
shapeid : "2_1206",
descr : "150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR",
insclass : "CP6A,CP6B",
gentype : "RECT_032_016_006",
machine : "SMT",
%package : "080450E",
%_item_number: "3",
%_Term_Seq : "" }
part "C30"
{ type : "1AB0081400 30",
shapeid : "2_1206 30",
insclass : "CP6A,CP6B 30",
gentype : "RECT_032_016_006 30",
machine : "SMT 30",
%package : "080450E 30 ",
%_item_number: "3 30 ",
%_Term_Seq : "30" }';
preg_match_all('/^part\s"(?P<ref>[^"]*)"[^{]*{
(?:(?=[^}]*\sdescr\s*:\s+"(?P<descr>[^"]*)"))?
(?=[^}]*\stype\s*:\s+"(?P<partnumber>[^"]*)")/imsx',$sourcestring,$matches);
echo "<pre>".print_r($matches,true);
?>
preferences:
34.69 ms | 402 KiB | 5 Q