route partialmatch? / feature request

Jan 10, 2010 at 12:35am

route partialmatch? / feature request

I’d like to be able to use a message like this in route:

[route playerblob%s]

that would route messages like:
playerblob01 or playerblobBall

Is there an object that does this?

I’m sure I could hack something together, but there must be a more efficient way…

#47674
Jan 10, 2010 at 1:40am

the almighty regexp, at your service:

– Pasted Max Patch, click to expand. –
#171416
Jan 10, 2010 at 1:59am

Thank you so much! Looks like I really need to get to know this object. I’ve kind of avoided it, because it is not so “plug and play”.

#171417
Jan 10, 2010 at 2:10am

not quite what I needed. I’d like it to work more like a route object. I guess i could use regexp to dynamically set a route, but maybe it is possible all in regexp? I don’t know perl and couldn’t find the answer in the help file. See attached patch to see what I am trying to do.

Thanks for the help.

– Pasted Max Patch, click to expand. –
#171418
Jan 10, 2010 at 3:34am

You could try [regexp playerblob\w+\s(.+)$] where the second outlet will report successful matches and the fourth will report failures. However this expression will only match messages with extra arguments, things like “playerblobBALL” and “playerblobPLAY” will not match. I’ll keep looking into it though, let me know if this is enough.

lh

#171419
Jan 10, 2010 at 10:11am

Hi Christopher,
With regexp and what bbracken suggested and what you’d like to do, I would probably do something like this with zl objects :

– Pasted Max Patch, click to expand. –
#171420
Jan 10, 2010 at 11:00am

Is this what you want?

– Pasted Max Patch, click to expand. –

You can use the backreferences output for your routed output, and the not matched output to pass on for further processing if you want exact route like functionality – this is a similar approach as Luke Hall suggests (use brackets to set the backreference section of the regexp), but it should matches ANYTHING after the playerblob – with or without spaces – basically regexp can do what you need – but you need to be totally clear on exactly what cases should match and which shouldn’t – http://www.regular-expressions.info/ is a pretty useful reference for this stuff…

Alex

#171421
Jan 10, 2010 at 12:12pm

Shhh. Promise not to tell anyone of the jstrigger object, it’s a secret.

– Pasted Max Patch, click to expand. –

_
johan

#171422
Jan 10, 2010 at 2:14pm

I couldn’t figure out a way to do it all in one [regexp] but here’s an abstraction that mimics [route] with one argument. It will even send a “bang” if there is a match but nothing extra to route. It will currently match “playerblob hello 3″ i.e. no extra symbol appended directly to “playerblob” but if you want a match like that to fail, simply change the *asterisk* in each [regexp] to a +plus+ and it should work.

lh

– Pasted Max Patch, click to expand. –
#171423
Jan 10, 2010 at 5:56pm

Luke – cool patch, but is there a reason that you are matching at the end of the string?

This isn’t how route works. Currently your abstraction will match:

nomatch playerblob01 ereoiu erueriu

I don’t think it should do that for route like functionality. Also you can do the matching in one regexp – but an exact match will give you a null string “” rather than a bang. A working regexp would be:

regexp playerblob\w*\s?(.*)

Regards

Alex

#171424
Jan 10, 2010 at 7:02pm

Not sure why I left the $dollar$ sign in there but you’re right. To solve the problem you mentioned simply add a ^caret^ to the beginning of each [regexp] search string. You’d need to do the same for the one you posted above too!

lh

#171425
Jan 10, 2010 at 7:31pm

So I found [tap.route @searchstring playerblob @partialmatch 1] does exactly what I needed. Attached is many of the approaches everyone so kindly provided. Many of them almost work. I’m not sure I understand luke’s last suggestion. I’d like to use regexp for this as the patch needs to be easily portable and tap.tools requires a license, but at least its working. Thank you everyone for your help.

– Pasted Max Patch, click to expand. –
#171426
Jan 10, 2010 at 7:47pm

Here’s the fixed version that won’t match something beginning “NOTplayerblob” etc. It’s kinda hard to figure out exactly what you want seeing as I don’t have the tap tools externals so I don’t know all possible inputs and the outputs you want in each case. Hopefully this will work for you though.

lh

– Pasted Max Patch, click to expand. –
#171427
Jan 10, 2010 at 10:17pm

Yes – luke you’re totally right – proper route functionality you need to explicitly match at the start of the string – for some reason that didn’t occur to me as the problem – rather that you where explicitly matching at the end…

Thanks for that – I might need that in future…

A.

#171428

You must be logged in to reply to this topic.