public static boolean replace(RTextArea textArea,String toFind,String replaceWith,boolean forward,boolean matchCase,boolean wholeWord,boolean regex) throws PatternSyntaxException {
  textArea.beginAtomicEdit();
  try {
    if (regex) {
      return regexReplace(textArea,toFind,replaceWith,forward,matchCase,wholeWord);
    }
    makeMarkAndDotEqual(textArea,forward);
    if (find(textArea,toFind,forward,matchCase,wholeWord,false)) {
      textArea.replaceSelection(replaceWith);
      return true;
    }
  }
  finally {
    textArea.endAtomicEdit();
  }
  return false;
}

public static boolean replace ( RTextArea textArea , String toFind , String replaceWith , boolean forward , boolean matchCase , boolean wholeWord , boolean regex ) throws PatternSyntaxException { textArea . beginAtomicEdit ( ) ; try { if ( regex ) { return regexReplace ( textArea , toFind , replaceWith , forward , matchCase , wholeWord ) ; } makeMarkAndDotEqual ( textArea , forward ) ; if ( find ( textArea , toFind , forward , matchCase , wholeWord , false ) ) { textArea . replaceSelection ( replaceWith ) ; return true ; } } finally { textArea . endAtomicEdit ( ) ; } return false ; }
finds the next instance of the text / regular expression specified from the caret position . if a match is found , it is replaced with the specified replacement string .
