.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 - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -