Class: QgsStringReplacementCollection

class qgis.core.QgsStringReplacementCollection

Bases: sip.wrapper

A collection of string replacements (specified using QgsStringReplacement objects).

QgsStringReplacementCollection(replacements: Iterable[QgsStringReplacement] = []) Constructor for QgsStringReplacementCollection

Parameters:

replacements – initial list of string replacements

QgsStringReplacementCollection(QgsStringReplacementCollection)

Methods

process

Processes a given input string, applying any valid replacements which should be made using QgsStringReplacement objects contained by this collection.

readXml

Reads the collection state from an XML element.

replacements

Returns the list of string replacements in this collection.

setReplacements

Sets the list of string replacements in this collection.

writeXml

Writes the collection state to an XML element.

process(self, input: str) str

Processes a given input string, applying any valid replacements which should be made using QgsStringReplacement objects contained by this collection. Replacements are made in order of the QgsStringReplacement objects contained in the collection.

Parameters:

input (str) – input string

Return type:

str

Returns:

input string with any matches replaced by replacement string

readXml(self, elem: QDomElement)

Reads the collection state from an XML element.

Parameters:

elem (QDomElement) – DOM element

See also

writeXml()

replacements(self) List[QgsStringReplacement]

Returns the list of string replacements in this collection.

Return type:

List[QgsStringReplacement]

setReplacements(self, replacements: Iterable[QgsStringReplacement])

Sets the list of string replacements in this collection.

Parameters:

replacements (Iterable[QgsStringReplacement]) – list of string replacements to apply. Replacements are applied in the order they are specified here.

See also

replacements()

writeXml(self, elem: QDomElement, doc: QDomDocument)

Writes the collection state to an XML element.

Parameters:
  • elem (QDomElement) – target DOM element

  • doc (QDomDocument) – DOM document

See also

readXml()