Created
April 22, 2023 12:37
-
-
Save mybedhome/7550d63ed1b8913b451a6daa8f4ae86b to your computer and use it in GitHub Desktop.
匹配字符串${}括号里的内容
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
const str = '{"a": "${默认:发起人}", "b": "${點认:组织}", "c": "${默认: 标题}"}'; | |
const regex = /\$\{([^}]+)\}/g; | |
const matches = str.match(regex); | |
console.log(matches); // 输出 ["${默认:发起人}", "${點认:组织}"] | |
const str2 = matches.join(""); | |
console.log(str2) | |
const regex2 = /[^\$\{\}]+/g; | |
const matches2 = str2.match(regex2); | |
console.log(matches2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment