stuckwithcode Posted January 14, 2010 Share Posted January 14, 2010 Hello, the code below will replace the word hello with a line break. text = text.replace(/hello/gm,"\n"); Just out of curiosity could someone please tell me how I would replace hello with the text \n not the line break. Thanks Link to comment https://forums.phpfreaks.com/topic/188438-simple-question-on-replace/ Share on other sites More sharing options...
salathe Posted January 14, 2010 Share Posted January 14, 2010 You simply need to escape the backslash: "\\n" Link to comment https://forums.phpfreaks.com/topic/188438-simple-question-on-replace/#findComment-994794 Share on other sites More sharing options...
stuckwithcode Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks I thought it would be simple. Link to comment https://forums.phpfreaks.com/topic/188438-simple-question-on-replace/#findComment-994795 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.