Reuse a Regexp token

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Reuse a Regexp token Fri Apr 25, 2014 4:03 pm • by simonszu
I have a sorting rule which should match on multiple patterns, like "aaaa {title}" and "bbbb {title}".
I created the first criteria, and told the rule to use the custom title token to create some tags and stuff.
Now i am stuck in creating the second criteria. I cannot recycle the title token from the first one, can i? Because it is not listed in the match filters, nor in the custom ones in the second criteria.
I _could_ however create a second token with the same regular expression as the first one, and name it title2 or something.
But then i don't know how to differentiate between both tokens when creating the tags. Because some files have the title token attached, and some have title2...

To cut a long story short: How can i reuse a custom defined token in multiple criterias for the same rule?
simonszu
 
Posts: 2
Joined: Fri Apr 25, 2014 3:57 pm

Re: Reuse a Regexp token Mon Apr 28, 2014 3:13 pm • by Mr_Noodle
There's no way to do it at the moment. You need to either consolidate them into one pattern or use multiple conditions.

I am considering adding the ability to have custom tokens be available to other conditions. There are issues, though. For instance, say you create •title in the first condition. In the second condition, you add •title. What does that mean? What if both conditions match? What is the value captured by •title?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Reuse a Regexp token Mon Apr 28, 2014 3:33 pm • by simonszu
Well, then do just a simple FCFS. The first condition that matches fills the token. You do it as well in the rules. If more than one rule matches an event, the first rule in the list is executed.
simonszu
 
Posts: 2
Joined: Fri Apr 25, 2014 3:57 pm

Re: Reuse a Regexp token Tue Apr 29, 2014 3:13 pm • by Mr_Noodle
Well, my current thought is this:

- First time it matches, it captures that value.
- Subsequent times that custom token is used, it needs to match against the captured value, not the pattern.

The benefit of this is that you can do rules where you match if a file's name matches another file's name, or the name of the enclosing folder, for instance. It opens up a nice set of functionality not available before without a script.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support