RegExSub#

class pyCGM2.Utils.prettyfier.RegExSub(pattern, flags=0, replace_with='')#

Dict factory for regex and corresponding substitution expression. .. attribute:: regex

Compiled regex to use in re.search()/match()

type:

re.Pattern

replace_with#

Description

Type:

TYPE

__init__(pattern, flags=0, replace_with='')#

Create RexExSub instance. :param pattern: String to compile as regex. :type pattern: str :param flags: Flags for re.compile(). :type flags: re.RegexFlag, optional :param replace_with: String to replace regex matches. Default :type replace_with: str :param removes match by replacing with empty string.:

Methods

__init__(pattern[, flags, replace_with])

Create RexExSub instance.

sub(string)

Perform regex substitution on given string.

sub(string)#

Perform regex substitution on given string. :param string: String to be processed. :type string: str

Returns:

str – String after replacements made.