user3502617
user3502617

Reputation: 21

I do not remember how to use the /* in javascript

So I have a bit of a problem. I don't remember how to use the /* in JavaScript like after the URL

example.

if(URL == "www.thing.com/"){}

So I don't remember were to place the /* to make it so it's not just "www.thing.com" but every other thing that comes after that, for example "www.thing.com/questions/...".

Would it just be "www.thing.com/*"?

Upvotes: 1

Views: 51

Answers (2)

3y3
3y3

Reputation: 802

You can use RegExp like this /^www\.thing\.com\/.*/

Upvotes: 0

Oriol
Oriol

Reputation: 288120

* in a string doesn't do magic.

You can use String.prototype.indexOf:

var URL = "www.thing.com/foo/bar";
if(URL.indexOf("www.thing.com/") === 0){ /* this is executed */ }

or, if you want a more flexible wildcard, use regular expressions.

Upvotes: 4

Related Questions