replace a frame [ 871 views ]
Goal: remove marker from a text
The problem is simple. I have a markered text like this:
this is <span class="mark">mark</span>ered
and I want to remove the marker structure quickly. The solution with regex back-reference:
x = x.replace(/(<span class="mark">([^<]+)<\/span>)/ig, '$2');
where
x the markered text itself
$1 (not used) is the main regex: (<span class=”mark”>…<\/span>)
$2 (what we need to keep) is the second regex: ([^<]+)