having a javascript string
var s = ' hi there \n <textarea> hello \n there </texarea> hi \n hi';
anybody knows how to do a replace of \n to <br/> that will only affect the \n symbols outside of the textarea ?
the result should be this:
'hi there <br/> <textarea> hello \n there </texarea> hi <br/> hi';
For a single textarea, you can use
matchto select the textarea. Then, usereplaceusing a Regular expression with the global flag to replace all newlines by<br/>.If you have to support multiple textareas, you can use a
forloop in conjunction with theexecmethod of the Regular expression object.