var str = "2001234560300";
var n = str.startsWith("200 ----> 300",0);
if (n == true)
{
alert('yes');
}
else
{
alert('no');
}
//How to check if my string starts with numbers from 200 to 300 in javascript ?
How about using a regular expression like that:
if (/^(2\d\d|300)/.test(str)) {
// do something
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.