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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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.