Reputation: 441
I have the following code (currHost is hostname):
if (currHost.match(/(alpha|beta|test|dev|load|local)\./))
but I need to add additional conditions such as
file:
Example MATCHING URLS:
Example NOT MATCHING URLS:
not sure how to approach this?
Thanks!
Upvotes: 0
Views: 246
Reputation: 1309
For your file matches you can simply use
document.location.protocol == 'file:'
and the expression you're looking for is
curHost.match(/(alpha|beta|test|dev|load|local|\.od.*|dev-wa|\.sq.*|\.hbox)\./)
Just remember that this expression will also match www.od.mydomain.com and oddmydomain.com since it's a valid match too. If you don't want this, you need to either specify a full expression (with the .com part) or specify the number of characters after the od/sq part. For example
curHost.match(/(alpha|beta|test|dev|load|local|\.od.{1}|dev-wa|\.sq.{1}|\.hbox)\./)
For one letter match.
If you want to specifically match those string only in the beginning of the domain, with or without www. you can use
curHost.match(/^(www\.)?(alpha|beta|test|dev|load|local|od.+|dev-wa|sq.+|hbox)\./)
Upvotes: 1
Reputation: 16123
if (currHost.match(/(alpha|beta|test|dev|load|local|file:|dev-wa|od\*|hbox)?\./))
Just add like above? Or do you mean something else?. I've added the a slash in from of the asterix. Added a questionmark at the end to make it ungreedy
Upvotes: 0