正規表現で始まるすべての行を照合する必要があります。サンプル入力。
#X0 alpha numeric content that I want
#X1 something else
#X26 this one as well
これらの正規表現はどちらも機能しますが、最初の行のみです。#X\d{1,2} のすべての行と照合する必要があります。
/^(\#X\d{1,2}\s+)(.*?)$/m
/^(\#X\d{1,2}\s+)(.+)*$/m
上記の正規表現のいずれかで得られるもの。
$pattern= "/^(\#X\d{1,2}\s+)(.+)*$/m";
preg_match($pattern, $content, $match);
echo $match[1];
alpha numeric content that I want
望ましい出力。
alpha numeric content that I want
something else
this one as well