Posted 21 December 2013 - 04:03 AM
I just found code that does this:
orig = orig.replace( "<br>", "<br>" ); orig = orig.replace( "<BR>", "<br>" ); orig = orig.replace( "<bR>", "<br>" ); orig = orig.replace( "<Br>", "<br>" );
I see why it's done this way (to encompass any caps variation on the BR) but since .replace() will only get the first instance, this is just bad all the way around. Also, there's no way to do a toLowerCase() because that will mess up the rest of the string.
Is there some sort of JS regex way to replace all instances of <br> regardless of the caps?
Posted 21 December 2013 - 04:21 AM Best Answer
orig = orig.replace(/<br>/gi, "<br>");/g is what makes it replace every instance while /i gives you the case insensitivity.
Edited by requinix, 21 December 2013 - 04:23 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users