Removing values in a list with * before the value

unhandled
list

(W1659313) #1

Hi all,

I’ve got a small problem with a large list. It’s probably an easy one, I’ve been trying a few alternatives but there doesn’t seem to exist a cull item created to remove values that have an * at the beginning of their value. Does such a component exist or do I have to amend my list before using grasshopper?


(David Rutten) #2

That would be a pretty specific component to have. Do you mean you want to remove all entries in a list of text data that start with the asterisk?


(W1659313) #3

That’s exactly what I’m trying to do. Would it be easier if I changed to another value in order to parse them in grasshopper?


(David Rutten) #4

Asterisks are harder to match since wildcard notation doesn’t like them, but you can use a Regex pattern instead:

The pattern you need is a backslash (which indicates the asterisk is treated as a regular character rather than its usual special meaning), then the asterisk and finally a dot to represent the rest of the pattern.


(W1659313) #5

Sorry David but I didn’t understand a thing in your first phrase, I had to look up wildcard notation and regex pattern. Did you mean that the asterix is too much of a versitile notation?

You advise me to change my data from “*value” to “*.value”? Sorry if these questions are a bit basic but treating list in grasshopper is definitely not my strong point.


(David Rutten) #6

Asterisks are fine, you just can’t use simple wildcard notation (the P input of the Match component) so you have to switch to RegEx instead, which is more complicated. But it still works, as the image shows.


(W1659313) #7

ah I found where my error was coming from and it just showed I didn’t undertsand what you meant the first time. I had my panel with *. plugged into the Pattern input and not the Regex…

Thanks a lot David, It works like a charm now.