@ReplaceSubString JavaScript Equivalent

Author: Tripp W Black

Created: 04/17/2002 at 09:48 AM


Notes Developer Tips

JavaScript Equivalent of @ReplaceSubString:

//Replace the blank characters with a plus sign - this will be removed in the queryopenagent
searchForKey = replaceString(" ","+",searchForKey)

//Actual function
//oldS is what character you want replaced
//newS is what character will replace it
//fullS is the variable you are manipulating
function replaceString(oldS,newS,fullS)
{// Replaces oldS with newS in the string fullS
for (var i=0; i<fullS.length; i++)
{ if (fullS.substring(i,i+oldS.length) == oldS)
fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
return fullS

In the query open agent, I have lotusscript taking out all of the plus signs.



Another way: (Chris Boote)

var parameter=document.forms[0].parameter.value
var qstring=document.forms[0].qstring

parmArray=parameter.split(' ')


// Create the instance of your string
var myString = new String ("Mr. R. Allen Wyke");

//Search for "Wyke" anhd replace it with "White"
var myRegExp = /Wyke/g;
var nhewString = myString.replace(myRegExp, "White");

previous page