Skip to content

Conversation

@kamil-kielczewski
Copy link
Contributor

More letters

More letters
@hazzik
Copy link
Contributor

hazzik commented Sep 9, 2020

There are many ways to get these letters. Why this particular way?

@kamil-kielczewski
Copy link
Contributor Author

kamil-kielczewski commented Sep 9, 2020

@hazzik This trick is non-trivial and allows to get RegExp without using any deprecated or semi-deprecated method (like escape)

Function("return"+(NaN+""["matchAll"]("")).slice(10,17))()("pattern")

after partial expansion:

[]["flat"]["constructor"]("return"+[10]["concat"](17)["reduce"](""["slice"]["bind"]((NaN+""["matchAll"]("")))))()("pattern")

but may be better place will be "Alternatives" section (?)

@hazzik
Copy link
Contributor

hazzik commented Sep 9, 2020

@kamil-kielczewski use split(" "):

Function("return "+(NaN+("")["matchAll"]()).split(" ")[1])

@kamil-kielczewski
Copy link
Contributor Author

Yep so we have

[]["flat"]["constructor"]("return "+([]+("")["matchAll"]())["split"](" ")[1])()("pattern")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants