How to replace tags with a javascript function from beginning to end? -


here problem, while using replace javascript function in order replace html tags bbcode tags, encountered issue:

what wanted:

[b]some text[/b], [b]other text[/b]. 

what i've got:

[b]some text</b>, <b>other text[/b]. 

this way wrote this:

mystring.replace(new regexp('<b>(.*)</b>','gi'),'[b]$1[/b]'); 

i know example replace way:

mystring.replace('<b>','[b]').replace('</b>','[/b]'); 

but thing want use divs specific id... if replacing opening , ending tags separately, wouldn't able replace '</div>' properly.

is there way have function run through string "linearly", beginning end, rather extremities towards center ? (my biggest problem not able formulate question properly, hence lack of results while searching web.)

thank input may provide.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -