以下はテキストファイルです。正規表現を使用して、後に始まる証明書を保存したいと思います
"crossCertificatePair;バイナリ::"
これは新しい証明書の始まりを象徴し、最後まで実行されます。各ファイルには同じ方法で始まる複数の証明書があり、それぞれを抽出して変数に保存する方法が必要です。
># extended LDIF
#
# LDAPv3
># base <cn=Federal Bridge CA,ou=FPKI,o=U.S. Government,c=US> with scope subtree
># filter: (objectclass=*)
># requesting: crossCertificatePair
>#
># Federal Bridge CA, FPKI, U.S. Government, US
dn: cn=Federal Bridge CA,ou=FPKI,o=U.S. Government,c=US
crossCertificatePair;binary:: MIINq6CCB2IwggdeMIIGRqADAgECAhAEBsw2n1386M2IP4F9
Y9f9MA0GCSqGSIb3DQEBCwUAMGQxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxG
TAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xIzAhBgNVBAMTGkRpZ2lDZXJ0IEZlZGVyYXRlZCBJRC
BDQS0xMB4XDTExMTIwNzEyMDAwMFoXDTE0MTIwNzEyMDAwMFowUjELMAkGA1UEBhMCVVMxGDAWBgN
VBAoTD1UuUy4gR292ZXJubWVudDENMAsGA1UECxMERlBLSTEaMBgGA1UEAxMRRmVkZXJhbCBCcmlk
Z2UgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5M26e4VUSlib2braFWKYhaUs3Q
SR9JwuQQHZQTmuhTOQScPO7g/JAdNvTFymOIHnXrinkPmOG+YyqxQQemNdIq3yi5AAUt+I6VOhsfS
NhZTZJsSKoNsZ72TxqOVkLMvKWNyZxvcZK3bG1wx5eErtKqlRMjTovxGXwVktB4/J+iu975SIxT1m
IaNsNWtyQOUF3T4P7K8/u1VwPmZ2SjMNYjKnFQU7E0Vfo1OEGWUrR0KrSBUT2Vu6PSj2OwkGr5ep6
rr+2vjboHpWG64qOoBQHyGwd7u6f/2TPkoD5OOqGdKOD4byifwi4L5arausnxY+Yy7jMM+ifG1qKD
GgupMJj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