You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/match-at
侯晓宇 0cb2601919
init
4 weeks ago
..
lib init 4 weeks ago
LICENSE init 4 weeks ago
README.md init 4 weeks ago
package.json init 4 weeks ago

README.md

match-at Build Status

Introduction

Like String.prototype.match if it only checked the regex at the given index instead of searching the entire string.

matchAt(/world/, 'hello world', 6);  // ['world']
matchAt(/world/, 'hello world', 0);  // null

Almost like 'hello world'.slice(i).match(/^world/) except the resulting match object's .index property corresponds to the original string, and it doesn't actually slice the string. Most engines optimize taking a substring so this probably isn't particularly valuable in practice, but it was an entertaining exercise and could be useful if you reminisce about these semantics.

License

MIT.