第一种方法很简单:
var str='abcdefg'; alert(str.substring(4));
第二种方法用正则:用起来还显麻烦
var str='abcdefg'; var re=/efg/; if(re.test(str)){ var efg=str.substring(str.indexOf('efg')); alert(efg) }
这里用到两个截取字符串的方法:
indexOf():方法可返回某个指定的字符串值在字符串中首次出现的位置。
substring:如果只有一个参数,则是从什么位置开始,到结束