Using ASP.NET, and trying to implement friendly url re-writing but I’m having a heck of a time working with the regular expression. Basically, I’m checking the url directly following the domain to see whether it is using the french-canadian culture, or whether it is a number – and not a number followed by characters. I need to catch anything that begins with ‘fr-ca’ OR a number, and both scenarios can have a trailing ‘/’ (forward slash), but that’s all…
fr-ca – GOOD
fr-ca/ – GOOD
fr-ca/625 – GOOD
fr-ca/gd – BAD
fr-ca43/ – BAD
1234 – GOOD
1234/ – GOOD
1234/g – GOOD
1234g – BAD
1g34 – BAD
This is what I’ve come up with : ^(fr-ca)?/?([0-9]+)?
But it doesn’t seem to be working the way I want.. so I started fresh and came up with (^fr-ca)|(^[0-9]), which still isn’t working the way I want. Please…HELP!
no idea about Asp.net, but the regexp was tested with grep. you could try in your .net box:
updated
—
well this may not be the best regex, but would be the most straightforward one.
it matchs string