I'm trying to validate a string with regex in javascript that a user inputs into a <form>that starts with http:// and contains a ~ somwhere within that string.
what I have is
(/^(http?:\/\/)\~/.test(string))
But it's not quite working.
Any tips?
If ( str.indexOf('http://') === 0 && str.indexOf('~') > 0 )???String.indexOfgives you the index of the string inside the string. If that index is0, the string starts with that string. If it's more than0it contains the string, if it's-1it does not contain the string.