regex - Problem with newline in JavaScript regexp -
i tried not show "spam" in string below using regex:
alert("{spam\nspam} _1_ {spam} _2_".replace(/{[\s\s]+}/gm, "")); what supposed see "~1~ ~2~"
(or that) got ~2~. why?
} , { elements of character class [\s\s]. should avoid matching by:
/{[^}]+}/g so regex stops once } found.
Comments
Post a Comment