.htaccess - Regex not matching the first occurence of my string -


in url:

 http://example.com/searchresult-empty.html?caty[]=12345&caty[]=45678 

i trying use following regex grab first occurence of caty should "12345". however, instead, regex below giving me final occurrence 45678. tried using "?" limiter make non-greedy per other stack overflow questions, isn't working. how can this?

 ^searchresult(?:.*)(caty)(?:.*)\=([0-9]+)\&?$ 

as far can tell, 2 things messing up:

  • the anchors ^ , $ seem forcing regex produce bad matches
  • you using greedy .* instead of non-greedy .*?
searchresult(?:.*?)(caty)(?:.*?)\=([0-9]+)\&?

should job


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -