Created
May 29, 2022 04:48
-
-
Save yano3nora/f454fb001f1914222c2b8a29d384b57d to your computer and use it in GitHub Desktop.
[js: RegExp] #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* string[] から /(パターン1|パターン2)/g みたいなやつ | |
* 動的につくりたいよおお | |
*/ | |
const words = ['パターン1', 'パターン2'] | |
const regex = new RegExp(`(${words.join('|')})`, 'g') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment