关于JS删除String里的字符的方法,一般使用replace()方法.但是这个方法只会删除一次,如果需要将string里的所以字符都删除就要用到正则. 1 2 3 4 var str = "abcdaabbssaaa"; var reg = new RegExp("a","g"); var a = str.replace(reg,""); console.log(a); 这里用 new RegExp()这个方法创建正则,第一
Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = "abcd" and B = "cdabcdab". Return 3, because by repeating A three