提取字符串我有這樣的一個字符串,我從API獲取請求得到的:PHP:從字符串
HTTP/1.1 404 Not Foundset-cookie: test-usercontext=asdf-client=200; path=
/set-cookie: test=AjQxMDMBABhNAEEATgBHAE8AIAAgACAAIAAgACAAIAACAAYyADAAMAADABBGAEIAVAAgACAAIAAgACAABAAYMgAwADEANgAwADQAMgA4ADEAMAAzADQABQAEAAAACAYAAlgACQACRQD
%2fA%2fowggP2BgkqhkiG9w0BBwKgggPnMIID4wIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBoIICwjCCAr4wggJ%21AgcgE
wUWFQk1MAkGByqGSM44BAMwRTELMAkGA1UEBhMCREUxDzANBgNVBAoTBlNBUC1BRzEMMAoGA1UECxMDRkJUMRcwFQYDVQQDDA4qL
ndkZi5zYXAuY29ycDAeFw0xMzA1MTYxNTA5MzVaFw0zODAxMDEwMDAwMDFaMEUxCzAJBgNVBAYTAkRFMQ8wDQYDVQQKEwZTQVAtQUcxDDAKBgNVBAsTA0ZCVDEXMBUGA1UEAwwOKi53ZGYuc2FwLmNvcnAwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA
%2f%21RvacHcYrHXGs0tkbb0V5pRZr%2166wpEefngcrA%2feo5VUyPFnjV%21VLPgYTlK5oVBT%21b8hVdVDF72%2fF7tG%2fzyNXjr6xCkACw69
%21NEBKQ4A7RSfLieN8IgCWl3ENA6cbgQJlhYMAugQexgN5rNX67eLyIFTEHGbF%2fkvlWXyDZt2AsCFQCCZiO7z37X8dHkeMyzasFRThlyFwKBgQC6
%2f4ZVeZJsMH528dpoLej8jEeUYstPpe6CFgIF7LqFjFnEWM%2fgt364k9%21kYRMdnN1l3Dgv2fHBOMET2lwiCSP%21Lp3JkDH9K
%21H9zLJfg%2fd3o5gNCu4pct9Au4%2fLh%21ejlgOAytMcr7z9G1SSaRKFk9QnzfyA4mmLmtDT6qZG%2fgx5%21wOBhQACgYEA%21rGBozVMIrQFy8mXlkOSDWiAo16gBBlLqAIhsc3Th
%2f6LFM%21HK8mzuxApdB8vDg5zOPQW959g2YmZBvMm7fBjjRyeQnh0SamBQNwdWR3cyhdXANRJTjdjV6yGJaBVUzMam5Yh2%2fNjwHWxS
%21Ev%21KNSUi7%2fHLrYjQ%2f5mYiipmBwOskwCQYHKoZIzjgEAwMvADAsAhQkPKrX2UIzsWHZoErU9zMKRjRMSwIUchu3vWrhXc2bckO
%21ASRCiCh3oF4xgf0wgfoCAQEwUDBFMQswCQYDVQQGEwJERTEPMA0GA1UEChMGU0FQLUFHMQwwCgYDVQQLEwNGQlQxFzAVBgNVB
AMMDioud2RmLnNhcC5jb3JwAgcgEwUWFQk1MAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3D
QEJBTEPFw0xNjA0MjgxMDM0NTdaMCMGCSqGSIb3DQEJBDEWBBTLTQarxV7dyga8cQOmMUBQNBc4mTAJBgcqhkjOOAQDBC4wLAIUUOp
%21DiZu22HaQ324gaZTLbbjWqICFCtwUwws0te2HqBON0OF%2faQ%21hLD3; path=/; domain=test.de; secure; HttpOnlyset-cookie
: asdf_SESSIONID=VMoFGADsOTEThFHqCdDaC9mG0O4NLBHmhakAUFaDZVE%3d; path=/; secure; HttpOnlycontent-type
: application/jsoncontent-length: 504x-csrf-token: dZgtpkwUMaN-gQ1X4QEXUw==dataserviceversion: 1.0x-asdf-e2eperf
: { asName: "ldai1_00", asType: "asdf", elapsed: 319, maxMem: 4595, dbTime: 166 }{"error":{"code"
:"005056A509B11EE1B9A8FEC11C21D78E","message":{"lang":"en","value":"Resource not found for the segment
'http:'."},"innererror":{"transactionid":"5721AEEC42F83183E10000000A4DA014","timestamp":"20160428103457
.6579540","Error_Resolution":{"error","Note":"Note 1797736
for error analysis"}}}}<br>
我想提取的X-CSRF令牌,這是上市後:x-csrf-token:。
在這種情況下,將
dZgtpkwUMaN-gQ1X4QEXUw ==
如何做到這一點的最好方法是什麼?
我使用preg_match_all嗎?但是,那麼,我有點失落。 謝謝你的任何建議。
爲什麼正則表達式只是執行字符串搜索 – anubhava