Jump to content

Possible to wildcard match snippet keywords?


Recommended Posts

I want to run a program every time I type something like ";today;"

But is there any way right now to do a pattern matched snippet so that I could have a snippet using regex like ";.*;" ?

 

Basically I want to make a date workflow where if I type in ";tomorrow;" it will replace that text with tomorrow's date. This seems like it would be a lot more seamless to use rather than having to cmd+space to bring up alfred, typing in the workflow keyword, and then typing in "tomorrow".

Link to comment

I should've explained better, that was one example.

 

I want to make a natural language datetime input.

 

So I should be able to type `;3d;` for 3 days from now, `;July 2;` and it'll insert July 2, 2020, `;3h;` for 11:26pm, etc.

So I don't want to hardcode all of these since there are so many.

Link to comment

Right, got you.

 

I doubt that regular expressions in snippet triggers will happen, as there's so much opportunity to mess things up. Like your example ;.*;. This is almost certainly incorrect, as it will match ;; (.* means "0 or more characters"), but more importantly, it also dangerous because it will match anything with two semicolons. Nobody wants Alfred to suddenly delete several lines of text from the email they're writing because it matched a poorly-written regular expression.

 

The potential for causing problems is massive without very, very carefully written regexes. As such, it's extremely unlikely to be added.

 

So I think you're best bet is to use what already exists: Snippet Triggers. Your defined snippet pops up Alfred's window, you enter your time expression in there (instead of inline), and then Alfred replaces the trigger text with the output of your workflow. My own Relative Dates workflow uses such a trigger to do something very similar to what you're aiming to do.

Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...