Reputation: 491
I need to check if a string starts with http://
in java script
What I have is
if(!txt.match(/^http:/)) {} // this only works for http:
I need to make it work for http://
can any one suggest a solution please?
Upvotes: 0
Views: 196
Reputation: 27765
You need to escape \
chars, also for checking is better to use test
method.
if(!(/^http:\/\//.test(txt))) {}
Upvotes: 1