LLLLLLL Posted December 21, 2013 Share Posted December 21, 2013 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? Thanks! Link to comment https://forums.phpfreaks.com/topic/284883-string-replace-caps-insensitive-whats-a-better-option/ Share on other sites More sharing options...
requinix Posted December 21, 2013 Share Posted December 21, 2013 Use regular expressions: orig = orig.replace(/<br>/gi, "");/g is what makes it replace every instance while /i gives you the case insensitivity. Link to comment https://forums.phpfreaks.com/topic/284883-string-replace-caps-insensitive-whats-a-better-option/#findComment-1462879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.