在 perl 中:
my base64_cert_data;
if ($certbuf=~/(-+BEGIN CERTIFICATE-+)(.*?)(-+END CERTIFICATE-+)/s) {
base64_cert_data = $2;
}
正则表达式解释:
/(-+BEGIN CERTIFICATE-+)(.*?)(-+END CERTIFICATE-+)/s
1st Capturing group (-+BEGIN CERTIFICATE-+)
-+ matches the character - literally
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
BEGIN CERTIFICATE matches the characters BEGIN CERTIFICATE literally (case sensitive)
-+ matches the character - literally
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
2nd Capturing group (.*?)
.*? matches any character
Quantifier: *? Between zero and unlimited times, as few times as possible, expanding as needed [lazy]
3rd Capturing group (-+END CERTIFICATE-+)
-+ matches the character - literally
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
END CERTIFICATE matches the characters END CERTIFICATE literally (case sensitive)
-+ matches the character - literally
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
s modifier: single line. Dot matches newline characters