Find 3 space before any word. ^\s{3}(?=\w) Find text between tag <h2>$1.1</h2> const matched_values = text.match(/(">\$)(.*?)</gm) const value = matched_values.length === 3 ? matched_values[2] : NaN