shortysbest Posted June 15, 2011 Share Posted June 15, 2011 My url for my website looks like: #/photos&id=1 (in that format for most of the time) there is one instance that i want it to look like this: #/photos&id=1/#/photo=98 but I want to select the first part, so I can have an if statement saying if #/photos&id=1 changes do this, else if /#/photo=98 changes do this so all I really need help is is with the regexp to match: #/photos&id=1 #/photos&id=1/#/photo=98 and that format, both will return: #/photos&id=1 only that Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/ Share on other sites More sharing options...
fugix Posted June 15, 2011 Share Posted June 15, 2011 $regexp = '/^.+(\#\/photos\&id\=1)+/i'; Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230072 Share on other sites More sharing options...
shortysbest Posted June 15, 2011 Author Share Posted June 15, 2011 Thanks, on the right track but I need it to match anything between #/ and / The variables can change, photos could be profile, and Id could be different Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230073 Share on other sites More sharing options...
fugix Posted June 15, 2011 Share Posted June 15, 2011 Thanks, on the right track but I need it to match anything between #/ and / The variables can change, photos could be profile, and Id could be different ah, okay $regexp = '/^.+\#\/(\w+\&id\=\d+)\/+/i'; Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230075 Share on other sites More sharing options...
shortysbest Posted June 15, 2011 Author Share Posted June 15, 2011 Everything between forward slashes should be matched, so if I had #/yshdjdk627:!:&/abc It would match everything between the fret set of forward slashes. I'm on my phone or else i would try it myself. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230076 Share on other sites More sharing options...
fugix Posted June 15, 2011 Share Posted June 15, 2011 which is what i gave you Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230079 Share on other sites More sharing options...
shortysbest Posted June 15, 2011 Author Share Posted June 15, 2011 You have id in there, I'd doesn't always have to be there Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230081 Share on other sites More sharing options...
fugix Posted June 15, 2011 Share Posted June 15, 2011 You have id in there, I'd doesn't always have to be there oh okay, misread your post $regexp = '/^.+\#\/(.+)\/+/i'; Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230084 Share on other sites More sharing options...
shortysbest Posted June 16, 2011 Author Share Posted June 16, 2011 I just got around to testing that, it doesn't seem to be working. (This is in javascript also, not php) Quote Link to comment https://forums.phpfreaks.com/topic/239443-reg-expression-to-match-this/#findComment-1230510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.