Reputation: 80
I have a string that contains some values in parentheses, and I would like to get only the first content that is within the first parenthesis with regex;
const str = "I (want to get this value), not this (value here)";
console.log(str)
Upvotes: 0
Views: 116
Reputation: 2123
const regex = /(?<=\().*?(?=\))/;
const str = `I (want to get this value), not this (value here)`;
console.log(regex.exec(str)[0]);
Upvotes: 1