I have a textarea where one can enter text (inputtext). Once the text is entered one can press a button and certain characters and words will be replaced in another textarea (outputtext). I want to do this: When the word faada (for example) shows up it will after the button is pressed read faada but when text such as faa or any other word containing aa (but not the word faada, the exception) is entered it will generate tt instead of the aa
For example: faa raa gaa faada haarry faada
After button is pressed: ftt rtt gtt faada httrry faada
I have tried
function addtext() {
var newtext = document.myform.inputtext.value;
newtext2=newtext.replace(/bfaadab/g, “faada”);
newtext3=newtext2.replace(/aa/g, “tt”);
document.myform.outputtext.value = newtext3;
}
Problem is that since aa is global (which I guess it has to be) the aa in faada will also be replaced with tt while I want that specific word to stay the same.
Can anyone help me 🙂