Get text between two rounded brackets

console.log(
  "This is (my) simple text".match(/\(([^)]+)\)/)[1]
);

\( being opening brace, ( — start of subexpression, [^)]+ — anything but closing parenthesis one or more times (you may want to replace + with *), ) — end of subexpression, \) — closing brace. The match() returns an array ["(my)","my"] from which the second element is extracted.

Leave a Comment