Posted 20 December 2013 - 11:03 PM
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 20 December 2013 - 11:21 PM 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, 20 December 2013 - 11:23 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users