Site logo

Archived topic

Backslash removed from regex when GP Premium activated

5 replies · Started by Tanya on April 6, 2018

Viewing posts 1–6 of 6

Hi,

I have the following Java Script code on one of my pages
words = words .replace(/^\s+|\s+$/g, '')

As soon as I activate GP Premium theme and save the page, backslashes get removed and I am left with
words = words .replace(/^s+|s+$/g, '')

I tried 2 slashes. When I save the page 1-st time, regex works because I am left with 1 slash. When I save page 2-nd time, regex stops working because escape character is not there.
words = words .replace(/^\\s+|\\s+$/g, '')

Could this be a bug in the theme? I am using sections.

Thanks

Hi there,

Are you putting javascript directly into the content editor?

Hi Tom. Yes. Other JavaScript code works fine. Just an issue with the slashes. Would you recommend another approach of inserting tha JavaScript?

Thanks

Hi Tom.
Thanks for the tip. I am using Scripts and Styles plugin now. Works great! :)

Awesome :)

This archived topic is closed to new replies.