Easy regex for someone who knows how to do them!
Posted on 2006-11-20
I have the following input , pattern and replacement:
input = "/suo/west_midlands/birmingham.aspx?"
pattern = "/suo/(\w+)/(\w+).aspx?"
replacement = "$1|$2"
when i run the match i get:
which is correct but when i change the underscore to be a dash it does not work!
as what i really want is a match for :
"/suo/west-midlands/birmingham.aspx?" ---> "west-midlands|birmingham?"
Can anyone spot what im missing and if so, could you explain why the pattern i currently have does not work for - but does for _ and also what is the correct pattern.
Thanks in advance