Jump to content
himat

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".

Share this post


Link to post

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.

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...