Greywacke Posted January 18, 2010 Share Posted January 18, 2010 i need to replace all instances of "<br />" with \n, yet it only replaces the first if i do it as follows: str.replace("<br />","\n"); i have tried googling for a solution, but all the answers were replacing "\n" with "<br />" as regular expressions (/\n//g with "<br />"), this has already been done.i've tried making the search for a regular expression as follows: str.replace(/<br />/g/,/\n/); and even with the / literal escaped, as well as the /g (otherwise i get undefined for g).: str.replace(/<br \/>/g/,/\n/); str.replace(/<br \/>\/g/,/\n/); even with the \n as a string: str.replace(/<br />/g/,"\n"); but to no avail... someone please help! i know after 10 years of javascripting and reading through manuals, i still don't quite get regular expressions. Link to comment Share on other sites More sharing options...
Greywacke Posted January 18, 2010 Author Share Posted January 18, 2010 nevermind, i managed to get the regular expression right str.replace(/<br \/>/g,"\n"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.