(self, fieldname, oldtext, newtext)
Returns a copy of this query with oldtext replaced by newtext (if
        oldtext was anywhere in this query).

        Note that this returns a *new* query with the given text replaced. It
        *does not* modify the original query "in place".
Returns a copy of this query with oldtext replaced by newtext (if
        oldtext was anywhere in this query).
Returns a copy of this query with oldtext replaced by newtext ( if oldtext was anywhere in this query ) .
def replace(self, fieldname, oldtext, newtext):
        """Returns a copy of this query with oldtext replaced by newtext (if
        oldtext was anywhere in this query).

        Note that this returns a *new* query with the given text replaced. It
        *does not* modify the original query "in place".
        """

        # The default implementation uses the apply method to "pass down" the
        # replace() method call
        if self.is_leaf():
            return copy.copy(self)
        else:
            return self.apply(methodcaller("replace", fieldname, oldtext,
                                           newtext))
def replace ( self , fieldname , oldtext , newtext ) : # The default implementation uses the apply method to "pass down" the # replace() method call if self . is_leaf ( ) : return copy . copy ( self ) else : return self . apply ( methodcaller ( "replace" , fieldname , oldtext , newtext ) )