preg_match('!<OperationResultError>(.*?)</OperationResultError>!is',$str,$m);
$str = '<Errors>
<OperationResultError>Validation error: Card.WorkProductName is empty or its content is incorrect.</OperationResultError><OperationResultError>Validation error: Defect.Name is empty or its content is incorrect.</OperationResultError></Errors>';
preg_match('!<OperationResultError>(.*?)</OperationResultError>!is',$str,$m);
print_r($m);
結果:
Array (
[0] => Validation error: Card.WorkProductName is empty or its content is incorrect.
[1] => Validation error: Card.WorkProductName is empty or its content is incorrect.
)
$str = '<Errors>
<OperationResultError>Validation error: Card.WorkProductName is empty or its content is incorrect.</OperationResultError><OperationResultError>Validation error: Defect.Name is empty or its content is incorrect.</OperationResultError></Errors>';
preg_match('!<OperationResultError>(.*)</OperationResultError>!is',$str,$m);
print_r($m);
結果:
Array (
[0] => Validation error: Card.WorkProductName is empty or its content is incorrect. Validation error: Defect.Name is empty or its content is incorrect.
[1] => Validation error: Card.WorkProductName is empty or its content is incorrect. Validation error: Defect.Name is empty or its content is incorrect.
)
少掉了 s 之後 以下兩行執行出來都是 相同的.
preg_match('!<OperationResultError>(.*?)</OperationResultError>!i',$str,$m);
preg_match('!<OperationResultError>(.*)</OperationResultError>!i',$str,$m);
$str = '<Errors>
<OperationResultError>Validation error: Card.WorkProductName is empty or its content is incorrect.</OperationResultError><OperationResultError>Validation error: Defect.Name is empty or its content is incorrect.</OperationResultError></Errors>';
preg_match('!<OperationResultError>(.*?)</OperationResultError>!i',$str,$m);
print_r($m);
結果:
Array (
[0] => Validation error: Card.WorkProductName is empty or its content is incorrect.
[1] => Validation error: Card.WorkProductName is empty or its content is incorrect.
)
沒有留言:
張貼留言