使用preg_match从字符串中提取密码?

时间:2010-07-14 22:01:59

标签: preg-match

如何使用preg_match从此字符串中提取secret_password? S:6: “secret_password”

1 个答案:

答案 0 :(得分:0)

如果你有一个以冒号分隔的字符串,最好使用explode(':', $string),但这是使用preg_match的答案

$subject = 's:6:"secret_password"';
$pattern = '/\"[^"]+\"/';
preg_match($pattern, $subject, $matches);
print_r($matches[0]);
相关问题