Match text component - in Python/faster?

Hi,

I noticed that the Match text component is becomming rather slow when the input lists becom quite long…

Would it help to make a '‘Match text’ component in the python component?

and how would this look like?

many thanks!

ps, same holds for ‘cull pattern component’

If you want to do a pattern search like the TMatch component does, you can use the re module (e.g. regex, regular expressions) in Python.

If you want to remove a string segment that is identified by a specific pattern, you can use re.sub(), which substitutes the identified substrings with another string (or void).

import re

s = "Rhino sucks..."
pattern = r"sucks\.*"
ss = re.sub(pattern, "rocks!", s)

print(ss)
# Rhino rocks!

Whether it’s faster is to be seen. Instead of inputting a list of strings, you could maybe join them into a single one, where they are delimited by a \n (i.e. new line) symbol, and process the entire string in one go.