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

silverlight - Applying a style to ItemContainerStyle in C# -

php - Retrieving comment count from fb:comments widget (Facebook) -

c# - NullReferenceException in MySqlClient.NativeDriver -