def run(self, params={}): flags = shared.constructFlags(params) regex = params.get(Input.IN_REGEX) split = re.split(regex, params.get(Input.IN_STRING), maxsplit=params.get(Input.MAX_SPLIT), flags=flags) return {Output.RESULT: split}
def run(self, params={}): flags = shared.constructFlags(params) regex = params.get(Input.IN_REGEX) new = params.get(Input.REPLACE_STRING, "") replace_num = params.get(Input.MAX_REPLACE) replaced = re.sub(regex, new, params.get(Input.IN_STRING), count=replace_num, flags=flags) return {Output.RESULT: replaced}
def run(self, params={}): flags = shared.constructFlags(params) regex = "(" + params.get(Input.IN_REGEX) + ")" findall = re.findall(regex, params.get(Input.IN_STRING), flags=flags) matches = [] for match in findall: if isinstance(match, str): matches.append([match]) else: matches.append(list(match)) return {Output.MATCHES: matches}