Client Side Regex Replace

Please implement Regex Replace on Client Side.

https://anvil.works/forum/t/regex-replace-not-working/9280

3 Likes

I just ran into this limitation when trying to do move some regular expression processing from the server to the client. The sub method being missing is making life difficult, as Iā€™m trying to process bbcode tags.

While waiting for this I use this function:

def re_sub(pattern, repl, text):
  matches = re.match(pattern, text)
  if matches:
    for i, match in enumerate(matches.groups(), 1):
      repl = repl.replace('\\{}'.format(i), match)
  return repl