Class: QgsStringReplacement

A representation of a single string replacement.

Methods

caseSensitive

Returns True if match is case sensitive

match

Returns the string matched by this object

process

Processes a given input string, applying any valid replacements which should be made.

properties

Returns a map of the replacement properties.

replacement

Returns the string to replace matches with

wholeWordOnly

Returns True if match only applies to whole words, or False if partial word matches are permitted

Static Methods

fromProperties

Creates a new QgsStringReplacement from an encoded properties map.

class qgis.core.QgsStringReplacement[source]

Bases: object

__init__(match: str | None, replacement: str | None, caseSensitive: bool = False, wholeWordOnly: bool = False)

Constructor for QgsStringReplacement.

Parameters:
  • match (Optional[str]) – string to match

  • replacement (Optional[str]) – string to replace match with

  • caseSensitive (bool = False) – set to True for a case sensitive match

  • wholeWordOnly (bool = False) – set to True to match complete words only, or False to allow partial word matches

__init__(a0: QgsStringReplacement)
Parameters:

a0 (QgsStringReplacement)

caseSensitive(self) bool[source]

Returns True if match is case sensitive

Return type:

bool

static fromProperties(properties: Dict[str | None, str | None]) QgsStringReplacement[source]

Creates a new QgsStringReplacement from an encoded properties map.

See also

properties()

Parameters:

properties (Dict[Optional[str], Optional[str]])

Return type:

QgsStringReplacement

match(self) str[source]

Returns the string matched by this object

Return type:

str

process(self, input: str | None) str[source]

Processes a given input string, applying any valid replacements which should be made.

Parameters:

input (Optional[str]) – input string

Return type:

str

Returns:

input string with any matches replaced by replacement string

properties(self) Dict[str, str][source]

Returns a map of the replacement properties.

See also

fromProperties()

Return type:

Dict[str, str]

replacement(self) str[source]

Returns the string to replace matches with

Return type:

str

wholeWordOnly(self) bool[source]

Returns True if match only applies to whole words, or False if partial word matches are permitted

Return type:

bool