Reputation: 1256
I'm trying to write a url rewrite regex expression. So if the url is bob.smith then good, if it's home.aspx, then not.
I have this so far:
^[a-zA-Z\-]+[.](?!aspx$|js$|css$|html$|htm$)[a-zA-Z\-]+$
So, first group, upper or lower case letters, the period, then the second group, upper or lower case letters, but not aspx, js, cs, html, htm.
Am i on the right track here?
Upvotes: 1
Views: 51
Reputation: 626952
Use
^[a-zA-Z-]+\.(?!(?:aspx|js|css|html?)$)[a-zA-Z-]+$
See the regex demo and the regex graph:
Details
^
- start of string[a-zA-Z-]+
- 1 or more letters or hyphens\.
- a dot
-(?!(?:aspx|js|css|html?)$)
- after the dot, there should not be aspx
, js
, css
, htm
or html
at the end of the string[a-zA-Z-]+
- 1+ letters or hyphens$
- end of string.Upvotes: 1