»
EnglishFrenchVietnamese

Print - Multiple search and replace - JavaScriptBank.com

Full version: jsB@nk » Utility » Search-code » Multiple search and replace
URL: http://www.javascriptbank.com/multiple-search-and-replace.html

Multiple search and replace © JavaScriptBank.comUse this JavaScript to search and replace string in your field.

Full version: jsB@nk » Utility » Search-code » Multiple search and replace
URL: http://www.javascriptbank.com/multiple-search-and-replace.html



JavaScript
<SCRIPT language=javascript type=text/javascript>// Mr Speedy July 2001//array of special charsxspecialChar = new Array('[',']','(',')')function specialChar(charIs){//checks if a char needs a backslash \ before it//this for loop with the help of Matt Burland <mcbst34+@pitt.edu>  for (var i=0; i<xspecialChar.length;i++) {      if(charIs==xspecialChar[i]) {      return true;      }    }return false;}function replace(form){var look4 = form.lookfor.valuevar newLookFor = ""var origText = form.orig.valuevar replaceWith = form.replacewith.valuevar delim = (form.caseSens.checked) ? "/g" : "/gi"var resultIs = ""   for (var i=0;i<look4.length;i++) {     var speChar = specialChar(look4.charAt(i)) var charToReplace = look4.charAt(i) if(speChar){ newLookFor += "\\" + charToReplace }else{ newLookFor += charToReplace }   }var myString = new String(newLookFor);var mySeparator = ',';var arrayName = myString.split(mySeparator) for (var i=0;i<arrayName.length;i++) {   if(i==0)  resultIs = origText.replace(eval("/"+arrayName[i]+delim), replaceWith);  if(i!==0)  resultIs = resultIs.replace(eval("/"+arrayName[i]+delim), replaceWith);  }form.result.value = resultIs}</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM style="text-align: left;">Input<BR><TEXTAREA name=orig rows=5 cols=100>The New International Version is a completely new translation of the Holy Bible made by over a hundred scholarsworking directly from the best available Hebrew, Aramaic and Greek texts. It had its beginning in 1965 when, afterseveral years of exploratory study by committees from the Christian Reformed Church and the NationalAssociations of Evangelicals, a group of scholars met at Palos Heights, Illinois, and concurred in the need for a newtranslation of the Bible in contemporary English. This group, though not made up of official church representatives,was transdenominational. Its conclusion was endorsed by a large number of leaders from many denominations whomet in Chicago in 1966. </TEXTAREA><BR>Look for<BR><INPUT size=30 value=is,the name=lookfor>   <INPUT type=checkbox name=caseSens value="ON">Case-sensitive<BR>Replace with<BR>  <INPUT value=was name=replacewith size="20"><BR>Result<BR><TEXTAREA name=result rows=5 cols=100></TEXTAREA><BR><INPUT onclick=replace(this.form) type=button value=Replace name=""> </FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->