eddy556 Posted September 16, 2008 Share Posted September 16, 2008 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 More sharing options...
effigy Posted September 16, 2008 Share Posted September 16, 2008 /Auth = .*/ Does the text following it include the equals sign? Are there new lines in the data? Link to comment https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643154 Share on other sites More sharing options...
eddy556 Posted September 16, 2008 Author Share Posted September 16, 2008 Yes it does, so in total it looks like: Auth=jsdfklajsldkfjlskdjflskjdflksajdlkfvkvjsdk Link to comment https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643157 Share on other sites More sharing options...
effigy Posted September 16, 2008 Share Posted September 16, 2008 In that case, /Auth=.*/. Link to comment https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643158 Share on other sites More sharing options...
eddy556 Posted September 16, 2008 Author Share Posted September 16, 2008 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 More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 <?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 More sharing options...
effigy Posted September 16, 2008 Share Posted September 16, 2008 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 More sharing options...
eddy556 Posted September 16, 2008 Author Share Posted September 16, 2008 Hi, using your examples I've figured it out: Auth(.+) That was all I needed! Couldn't have done it without your help though! Link to comment https://forums.phpfreaks.com/topic/124537-solved-ahhh-regex/#findComment-643210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.