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! Quote Link to comment https://forums.phpfreaks.com/topic/284883-string-replace-caps-insensitive-whats-a-better-option/ Share on other sites More sharing options...
Solution requinix Posted December 21, 2013 Solution Share Posted December 21, 2013 (edited) Use regular expressions: orig = orig.replace(/<br>/gi, "");/g is what makes it replace every instance while /i gives you the case insensitivity. Edited December 21, 2013 by requinix Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.