randomguy1234 Posted July 23, 2012 Share Posted July 23, 2012 I'm really clueless about regex. I've written a pattern: /<div class=\"search_result_item\" onclick=\"window.location='([^']+)/ My code is something like: randomcharacters <div class="search_result_item" onclick="window.location='/summoner/na/19997298'; return false;"> I need that "19997298" out of there, but I get: <div class="search_result_item" onclick="window.location='/summoner/na/19997298 Help me? I'm new to Regex Quote Link to comment Share on other sites More sharing options...
xyph Posted July 23, 2012 Share Posted July 23, 2012 Use var_dump($match) to see how the function is returning the results. Quote Link to comment Share on other sites More sharing options...
randomguy1234 Posted July 23, 2012 Author Share Posted July 23, 2012 It returns: array(2) { [0]=> string(79) " string(21) "/summoner/na/19997298" } Quote Link to comment Share on other sites More sharing options...
xyph Posted July 23, 2012 Share Posted July 23, 2012 Oh, silly me. Will the value before the number always be /summoner/na/, or is there a chance it won't be? Will there always be 3 forward-slashes before the number? Quote Link to comment Share on other sites More sharing options...
randomguy1234 Posted July 23, 2012 Author Share Posted July 23, 2012 Both true. Always /summoner/na/NUMBER and always only three slashes. Quote Link to comment Share on other sites More sharing options...
xyph Posted July 23, 2012 Share Posted July 23, 2012 So why not use something like $expr = "$<div class=\"search_result_item\" onclick=\"window.location='/summoner/na/([0-9]+)$"; 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.