How can I apply regex only within a certain scope, like between two **'s?
I want to use JavaScript to change this
**
_a_ _b_ _c_
-d- -e- -f-
**
_a_
into this
**
{a} {b} {c}
(d) (e) (f)
**
_a_
Notice that the desired result is that _a_ is not changed outside of the "scope".
I can do this much
str
.replace(/_(.*?)_/g, "{$1}")
.replace(/-(.*?)-/g, "($1)")
but this will replace everywhere, even outside of the two **'s.