function getPrefixValue($sContents, $sPrefix = \'value\')
{
unset($xValue);
$sPattern = \'/[\\s]+\'.$sPrefix.\'[\\s]*=[\\s]*(?:\\\"([^\\\"]*)\\\"|\\\'([^\\\']*)\\\'|([^\\\'\\\">\\s]+))/i\';
$bMatch = preg_match($sPattern, $sContents, $aResult);
if ( $bMatch ) {
$iValue = count($aResult) - 1;
$xValue = $aResult[$iValue];
} else {
$xValue = null;
}
return $xValue;
};
사용법은 예를들어서
$url = \'<a href=\"http://www.google.com\">잰장</a>\';
echo getPrefixValue($url, \'href\');
이러면 href 값만 뽑아온다
이거 제쯔가 만든거
감사하다능 ㅋ
php 정규식은 \\s \\d 이런거 쓸때 [] 이걸로 감싸야 되나 보네요 그나저나 문자열이라는 개념 자체가 없는건가 ㅎㄷㄷ 그냥 바로 인자가 정규식으로 들가네