Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Regex required

by vaibhav07 (Acolyte)
on May 03, 2012 at 17:57 UTC ( #968789=perlquestion: print w/ replies, xml ) Need Help??
vaibhav07 has asked for the wisdom of the Perl Monks concerning the following question:

$var = 'Please enter Certificate Signing Request(CSR): Press <Enter> w +hen done MIICxjCCAa4CAQAwgYAxFzAVBgNVBAMTDnRlc3QtY2VydC11c2VyMQswCQYDVQQG EwJVUzELMAkGA1UECBMCTkMxDDAKBgNVBAcTA1JUUDEPMA0GA1UEChMGTkVUQVBQ MQwwCgYDVQQLEwNDU0kxHjAcBgkqhkiG9w0BCQEWD3VzZXJAbmV0YXBwLmNvbTCC ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK8ICjh7p3ATkfZhabMvpgus w6/qqyLqyguM9dB5emr1e08y70fx9EL6FZ9uXMzm2K5QtZ7hF/yEvv5N3kxMjq7q uMx13okKYqhnC266CIZs3a+Z5g72MnRHsQwffIOB9tvY0h9KjvICSXbdYj8w4I7E 7hI8EDxdwXaUC7SZapFrueRPLyCMxQh6OqRxUZdxT9zXh/hEYVy2GRLMq00/QcUR qPTuSPfbzfTXVl7tdIGZmH7z9/wKwf2UZbtQ4LSJxGIyfMNnT5DJmEOgmy8fBMXh AhDfFOANKsZHQSszAS/z6VRHWNoTsTNQGSD9JGApnKSKBsRt4CG4Yu6sh7kpSmkC AwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQAF3/sC4XNdYnh1bzUN1CYHJyjRPzGv oNxIBmAw2p/huLkJA7JttNn8xQ9lwrMw/yE3MVs4Q2UOk8Ku0XxG6dt50uZjF4sA s3Ck2qPG/ptoOQr4QuYBxnZXVhe0k0LqWIDI+xtoTYxqYwSEe5vOImdN8u9EkJSD Sv7L0bKqnC2N86RjupaS8stRyefkaOmRxJfA7In0IyYDr/5yDzEnQLJK+T+Ijtgi aWKLLW2sihdBsEgG4uJAQOa4rDf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SywRZ YkI+YBAHeIG31Ig/dp7uefXFSCRhacE2bBdy2uniOTSVdh6RYh7cE2l9VMEaY1nO p1M7mM2Pa2Adti9ZSwzhwxjRcOD/qSrN3DR/EjuPFdPT1EyNvSOsw/2edsVWcAKp KB7MLblfq1zfxkAKMIO0vRJ4fVAyhke2pnWoz2plX86Vqv2Nv9Prw8V6iNpQrMCE 2O9KfqEP/Z3oHyHFcvgouVfe2caWBTtZeLFVwodf0GhRTtkM4zMkvfcOUr2utybp Gxqf/KABolKX1sZ6SSC16LkuR7OoJ7YBUMhrp+wjf/zjWCI= -----END CERTIFICATE-----'
Require a regex to match and obtain the complete string after "-----BEGIN CERTIFICATE-----" and before "-----END CERTIFICATE-----"
if ($var =~ /Signed(.*)\s+(.*)\s+(.*)/) { print"$3\n"; }

Comment on Regex required
Select or Download Code
Re: Regex required
by bobf (Monsignor) on May 03, 2012 at 18:11 UTC
Re: Regex required
by sauoq (Abbot) on May 03, 2012 at 18:38 UTC
    perl -nle '/-{5}BEGIN\sCERTIFICATE-{5}(.*?)-{5}END\sCERTIFICATE-{5}/s and print $1'
    -sauoq
    "My two cents aren't worth a dime.";
Re: Regex required
by Anonymous Monk on May 04, 2012 at 07:51 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://968789]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-07-28 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (195 votes), past polls