I use TextExpander (among other tools), but every once in a while I can’t figure out how to implement an expansion I’d like.
Example: any time I type 2-3 digits and then bpma, expand that to the digits followed by bpm average
With regex, I could match with something like: \d{2,3}bpma – but I don’t think TextExpander does regex
Is there some way to do this? If not with TextExpander, then KM, BTT (which I’m trialing … not much use yet tho) or one of the other expansion tools like Typinator or Expanso?
I’m pretty sure I could do it in Hammerspoon (which I use for some other automations), but of course it’s easier if someone has already done the work…
I should have said … and doesn’t require me to use JavaScript! I don’t love JavaScript… but you’re right, that would let me do this and just about anything else I need…
If I understand you correctly, you’re looking to write a trigger that includes some regex (i.e. so that whether you type 123bpma or 456bpma both will trigger the same expansion which will use regex capture groups to expand to 123 bpm average and 456 bpm average respectively.
I don’t think that’s possible with any text expansion product I’ve seen. (My guess is that the potential for trigger conflicts expands exponentially if the triggers themselves have regex.) I’d use TextExpander fill-ins for this instead.
Alternatively, if the expansion doesn’t need to happen in real time, you could just write a script to process and expand a text file after the fact.
I might be misunderstanding what you’re trying to do. It sounds like you want to type something like 85bpma and have that expand to 85 bpm average. In which case, you shouldn’t need to do anything with regex or scripting. You basically just need to trigger on bpma and change the delimiters so that it’ll expand when not preceded by a space (and then if you want there to be a space between the number and bpm once expanded, just put a space at the start of the expansion).
Edit: although I’ve just realised you might be saying you explicitly don’t want it to expand if not preceded by the numbers. Are there situations where you want to type bpma and have it not expand? In which case it may need a bit more thinking about.
I’m capturing the number into a variable here, which then opens up possibilities beyond a simple expansion. You could, for example, do a calculation on the bpm value and output something into the expansion based on that: