I’m working on this small code: http://jsfiddle.net/5kXBk/
If you type “foo $42 bar” in the first div, you get the correct text coloration. But if you add a new line and start writing, the text remains green…
How can I solve this?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re using
^and$in your RegExp. This causes the RegExp to only match only one string: a string which fully matches the pattern.Use the following RE instead, at fiddle: http://jsfiddle.net/5kXBk/7/
([^$]*)Any non-dollar sign(.*?)Any character(?=<br|$)Before an end (<br>or$) (contentEditableconverts newlines into<br>s)