I have a string for ex "adlkup.db.com" and I want to validate the string for ".com" at the end of the string.
var x = "adlkup.db.com";
So I am trying something like
/.com$/.test(x)
and the . is interpreting to some other regex which finds a single character, except newline or line terminator
lastIndexOf(".com")instead?myValue.lastIndexOf(".com") != myValue.length - 5) which will give youfalse` exactly like the regex does.myValue.lastIndexOf(".com")might be-1andmyValue.length - 5also be-1. So to avoid this I want to use regex. But it would be great if you can give me info on why it's not the better way to use regex for these kind of situations. Thanks in advance.