Jump to content

[SOLVED] Ahhh regex!


eddy556

Recommended Posts

Hi, I know this is most probably very very simple however no matter how hard I try I could never figure this regular expressions!

 

I have something like this:

Auth = (random text here)

 

This text is contained within another string with LOADS of other random data.  What I need is a regex which will match JUST Auth and the text following it.  At the end of the text there is no delimiters such as a full stop or anything just the end of the string.  It is a random length.

 

Many thanks and I'm pretty sure I should be able to understand once I see the answer!! :)

Link to comment
https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/
Share on other sites

Hmmm.....doesn't seem to work.  I have included the whole of the text that needs searched through:

 

SID=DQAAAIwAAADYBzOfXMgIg-QKywsJCyPM6bbx5YVkPsZQPTyaHy16Pa6uNB4RXteTVBzTXXPkKxMNNlU4YuEe3DiKYvaQMHAgh_JbJzaT5490_WvtwJwOCepSu_R4bYFyTwJe-y7CRg3MMwpVkXtwaf-8vbznovVBbjSzRDp7kRpdWW1TXtOlDD_Vn-G1-cTHRMyA25wlypI

LSID=DQAAAI4AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhADnL25OR8cuh8ZayssClsjlQh-2NenhdcQzX83Vfjvq1oxbSERlhfNGR88Hoy_DquC5KWF8saxjrvdeGVaLu-CktIDnTwtmd3Ozv_TxxXiM

Auth=DQAAAI0AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhpaLcYAjO4yvGhZbl93gru4A4LtlXFRtqPNHItkoc_EyttT0-2cT81jxRjuX5qQJjmYEAYPmW4N0zYGVIJm1j84PlMdxZfuakFeEGAwjuXxE

 

 

I am trying to extract the Auth=

 

Many thanks!

Link to comment
https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643164
Share on other sites

<?php
$string = <<<DATA
SID=DQAAAIwAAADYBzOfXMgIg-QKywsJCyPM6bbx5YVkPsZQPTyaHy16Pa6uNB4RXteTVBzTXXPkKxMNNlU4YuEe3DiKYvaQMHAgh_JbJzaT5490_WvtwJwOCepSu_R4bYFyTwJe-y7CRg3MMwpVkXtwaf-8vbznovVBbjSzRDp7kRpdWW1TXtOlDD_Vn-G1-cTHRMyA25wlypI
LSID=DQAAAI4AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhADnL25OR8cuh8ZayssClsjlQh-2NenhdcQzX83Vfjvq1oxbSERlhfNGR88Hoy_DquC5KWF8saxjrvdeGVaLu-CktIDnTwtmd3Ozv_TxxXiM
Auth=DQAAAI0AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhpaLcYAjO4yvGhZbl93gru4A4LtlXFRtqPNHItkoc_EyttT0-2cT81jxRjuX5qQJjmYEAYPmW4N0zYGVIJm1j84PlMdxZfuakFeEGAwjuXxE
DATA;
$matches = array();
preg_match('/Auth=(.+)$/im', $string, $matches);
print_r($matches);
?>

 

EDIT: Accidentally put 's' instead of 'i' for the modifier.

Link to comment
https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643178
Share on other sites

Ah, but it does:

 

<pre>
<?php
$string = <<<DATA
SID=DQAAAIwAAADYBzOfXMgIg-QKywsJCyPM6bbx5YVkPsZQPTyaHy16Pa6uNB4RXteTVBzTXXPkKxMNNlU4YuEe3DiKYvaQMHAgh_JbJzaT5490_WvtwJwOCepSu_R4bYFyTwJe-y7CRg3MMwpVkXtwaf-8vbznovVBbjSzRDp7kRpdWW1TXtOlDD_Vn-G1-cTHRMyA25wlypI
LSID=DQAAAI4AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhADnL25OR8cuh8ZayssClsjlQh-2NenhdcQzX83Vfjvq1oxbSERlhfNGR88Hoy_DquC5KWF8saxjrvdeGVaLu-CktIDnTwtmd3Ozv_TxxXiM
Auth=DQAAAI0AAAB1kKq-YnO_nW0K0EbSClfLvU5ZICX-12eQluWMdNLMFVkcUYREwf88uCGuqHVfJAgNvJNB-f6sJg4g1TkO11RhpaLcYAjO4yvGhZbl93gru4A4LtlXFRtqPNHItkoc_EyttT0-2cT81jxRjuX5qQJjmYEAYPmW4N0zYGVIJm1j84PlMdxZfuakFeEGAwjuXxE
DATA;
preg_match('/Auth=.*/', $string, $matches);
print_r($matches);
?>
</pre>

Link to comment
https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643200
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.