だから私はC++に翻訳したいそのようなphp関数を持っています:
protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
{
preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
$result = array_merge($matches1[1], $matches2[1]);
return empty($result)?false:$result[0];
}
使用例:
$location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content');
$server = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href');
$delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href');
(内容は の結果です$content= curl_exec($curl);
)
preg_match_all
- pattern で指定された正規表現に一致するすべての対象を検索し、それらを flags で指定された順序で一致に入れます。最初の一致が見つかった後、後続の検索は最後の一致の終わりから続行されます。
boost::regexp を使用して翻訳する方法は?