-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
25 lines (22 loc) · 864 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*!
* name: @jswork/next-regex-index-of
* description: JavaScript's String.indexOf() that allows for regular expressions.
* homepage: https://github.com/afeiship/next-regex-index-of
* version: 1.0.3
* date: 2021-01-09 16:26:13
* license: MIT
*/
(function () {
var global = typeof window !== 'undefined' ? window : this || Function('return this')();
var nx = global.nx || require('@jswork/next');
// https://stackoverflow.com/questions/273789/is-there-a-version-of-javascripts-string-indexof-that-allows-for-regular-expr
nx.regexIndexOf = function (inString, inRe, inStartPos) {
if (!inString) return -1;
var start = inStartPos || 0;
var idx = inString.substring(start).search(inRe);
return idx >= 0 ? idx + start : idx;
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = nx.regexIndexOf;
}
})();