This is from ExpressionEngine v2.0.1pb01 Build: 20100215
We ran into this issue recently while using a regular expression object in Javascript. Our regular expression was a rather simplified phone number validator:
/\(?\d{3}[-\) ]?\d{3}[- ]?\d{4}/The regular expression object was being declared like this:
var validPhoneExp = /\(?\d{3}[-\) ]?\d{3}[- ]?\d{4}/;When the template was saved all of the backslashes were removed from the regular expression leaving:
/(?d{3}[-) ]?d{3}[- ]?d{4}/;Which is obviously not what we wanted. After some hair pulling and interesting debugging, we found what it was doing and got around this by escaping the backslashes like this:
var validPhoneExp = /\\(?\\d{3}[-\\) ]?\\d{3}[- ]?\\d{4}/;And it works! The only issue is when we open the template again, it just has the one set of backslashes and so when we save it it removes those and leaves no backslashes again. I believe this is a bug due to escape characters when inserting the template into the database. I am unsure of what exactly is happening but it seems to be related to the MySql escape characters not being handled properly in a template.