php - getting url to work with or without a subexpression -


im trying rewrite url like

page.php?sort=66&search=s&category=2,3,4&archive=june&page=3

to

page-sort-1-search(s)-category-1,2,3-archive(june)-page3

but thing each of subexpressions or may not in url every time page called had put each 1 in "( )?" regex works or without them

^page (-sort-([0-9]*))?      (-search\(([a-z]*)\))?  (-category-([0-9][,]?*))?  

............. idea

now problem mode rewrite considering each 1 of subexpression in parenthesis actual variable

(-sort-([0-9]*))?  how mode rewrite interpret  => $1 = -sort-66  ,  $2 = 66  

so each subexpression got 2 capture-group , that's more 10 link 5-6 variable , there 9 match limit in mode rewrite

is there replacement "()?"

i have admit, i'm bit confused parts of question, apologize in advance if answer totally off-base . . . sounds need non-capturing group. this:

(...) 

matches ... , creates capture-group (what you're calling "variable"); this:

(?:...) 

just matches ..., without creating capture-group. it's useful if want group subexpression, without saving of contents used $1.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -