devWhiz Posted June 11, 2011 Share Posted June 11, 2011 I fail miserably at regex I need to get the string in between app# and &open so it would be $matches = "bz8D1qQq0rQHQ2WEQ5fGG3KIWNIFUqIhwwSRVlob%2b7bR7RH%3d"; app#bz8D1qQq0rQHQ2WEQ5fGG3KIWNIFUqIhwwSRVlob%2b7bR7RH%3d&open and if someone could post a link to where I might be able to grasp the preg_match function, aside from the manual that would be great.. Thanks Link to comment https://forums.phpfreaks.com/topic/239056-preg_match-help/ Share on other sites More sharing options...
wildteen88 Posted June 11, 2011 Share Posted June 11, 2011 and if someone could post a link to where I might be able to grasp the preg_match function, aside from the manual that would be great.. Thanks To learn how to use this function you'll want to learn regular expressions. regular-expressions.info is good learning resource and http://gskinner.com/RegExr/ is a good site for testing out your regex patterns. A regex pattern that you can use would be preg_match('~app#(.*)&open~', $string, $matches); preg_match will return an array of matches Array ( [0] => app#bz8D1qQq0rQHQ2WEQ5fGG3KIWNIFUqIhwwSRVlob%2b7bR7RH%3d&open [1] => bz8D1qQq0rQHQ2WEQ5fGG3KIWNIFUqIhwwSRVlob%2b7bR7RH%3d ) use $matches[1] to get the match string between the # and &. If you need to match multiple instances of app#{WHATEVER}&open then you'll need to use preg_match_all Link to comment https://forums.phpfreaks.com/topic/239056-preg_match-help/#findComment-1228291 Share on other sites More sharing options...
JAY6390 Posted June 11, 2011 Share Posted June 11, 2011 I'd recommend changing .* to .*? in the above regex to stop it being a "greedy" regex Link to comment https://forums.phpfreaks.com/topic/239056-preg_match-help/#findComment-1228295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.