Idea ID: 2758871

OO-Designer: cs-base-cp: Improve operation "filter_line"

Status : Waiting for Votes
over 1 year ago

I wrote a custom Python operation that enable me to use an custom delimiter and handle multiple regex groups. Maybe it is an idea to make a new operation in cs base content pack or improve the old operation?

Just an idea.

inputs:

text

regex

delimiter

 

here is my code:

import re
return_code = '0'
return_result = ''
error_message = ''

try:

reg = re.compile(regex)
finds = reg.findall(text)

for element in finds:
joinelement = ''.join(element)
return_result += joinelement + delimiter if element != finds[-1] else joinelement

except Exception as e:
return_code = '-1'
error_message = 'Exception: ' + str(e)

Tags: