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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -