Lists: Different results for build-in list-node and regex-node?


This is my first post here so unfortunately I’m not yet able to upload files.
I’ve been playing around with some data extraction and want to extract a part of a string.
I’ve installed the Clockwork-package and used their Regex.ReplaceRegularExpression-Node to get what I want.
It works just fine - the Watch-Node gives me the exact same result as the build-in List-Node.

Unfortunately, when I try to process this newly created list with a Python-Node, the build-in version does work while the regex version results in an empty list.
The code is exactly the same for both:

MyList = IN[0]
ListOutput = []

# Not too clean, I know
counter_lines = 1
counter_arcs = 1

for element in MyList:
    if element == "Line":
        enumeration_lines = element + str(counter_lines)
        counter_lines = counter_lines + 1
    elif element == "Arc":
        enumeration_arcs = element + str(counter_arcs)
        counter_arcs = counter_arcs + 1
# Assign your output to the OUT variable.
OUT = ListOutput

Can someone point me in the right direction?

There is an extra space at the beginning of your values from the Regex it looks like. Check that and make sure it trimmed correctly.

Oh my! Slightly embarassing.
I’ve been staring at this for an hour now and didn’t notice. Did the trick, it was one whitespace-character.
Thanks a lot! :slight_smile:

1 Like