fromIndex
옵션 str.indexOf(searchValue[, fromIndex])
String.prototype.indexOf
MDN에서
. 검색을 시작할 호출 문자열 내의 위치입니다. 정수가 될 수 있습니다. 기본값은 0
입니다.
n.b. 당신은 많은 문자에서 선택을 찾으려면 .indexOf
은 당신이 어느 것 루프 필요 정규식
정중 한 예를
var haystack = 'foo_ _IBAN: Bar _ _';
var needle = 'IBAN: ',
i = haystack.indexOf(needle),
j;
if (i === -1) {
// no match, do something special
console.warn('One cannot simply find a needle in a haystack');
}
j = haystack.indexOf(' ', i + needle.length);
// now we have both matches, we can do something fancy
if (j === -1) {
j = haystack.length; // no match, set to end?
}
haystack.slice(i + needle.length, j); // "Bar"
IBAN에는'\ W +'이면 충분합니다. – Bergi
감사합니다. @Bergi. 나는 어떤 문자가 포함되어야하는지 잘 모르겠다. 그래서 나는 그의 목표 공간을 구분 문자로 사용했다. –