Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class MyMatcher {
constructor(value) {
this.value = value;
[Symbol.match](string) {
var index = string.indexOf(this.value);
if (index === -1) {
return null;
return [`${this.value} altered`];
var fooMatcher = 'foobar'.match(new MyMatcher('foo'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.