-
-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex in trigger #146
Comments
Hey @Kwelity Sorry for the late reply, it's been a super busy week! Besides the UPPER/lower case insensitivity, which use-cases would benefit from it in your opinion? Thanks for your help :) |
Hum, my most "pressing" feature request would be simplify multi trigger with regex, I think I saw another issue about multi trigger. This would solve it just fine. What I could imagine doing if we had full regex support (I do understand that this is not a trivial feature and might be to demanding in term of performance) would be to capture pattern in a trigger that are then used in replace. Something like:
so that even better with script where group could be used as parameters:
Ok, this one I improvised on the spot, I'm not really sure how it would work, maybe pass the captured group as arguments. |
Hey @Kwelity, I agree that full regex support would be ideal. Unfortunately, due to the "realtime" nature of espanso, this is very difficult to achieve. That said, it seems like you want something along the lines of #118, which is one of the most requested features (hopefully coming soon). I'll think about a way to implement regex support anyway, thank you for the help :) |
@federico-terzi sure thing, I understand, I'll keep an eyes on the issue you mentioned. |
This would be a really cool feature. I use regex in Typinator app to correct double capitalized words. Example - DAsh to Dash. This is something that I regularly encounter when I hold the Shift key for slightly too long. Wish you would reopen this issue. |
@khaveesh Unfortunately, as I said, it's very unlikely that full regex support will make its way into espanso due to performance reasons (some users run up to 50k matches, can you imagine checking every one of them after each character is pressed? that would either be a performance disaster or require implementing a full parallel regex engine such as hyperscan which is out of scope at the moment). That said, if your goal is to correct double capitalized words, you can open an issue specifically for that :) |
In case anyone finds this via Google like me, Espanso by now has Regex triggers and the double capitalization fixing can be implemented with this: matches:
- regex: "\\b(?P<one>[A-Z])(?P<two>[A-Z])(?P<three>[a-z])"
replace: "{{CapitalCased}}"
vars:
- name: CapitalCased
type: shell
params:
cmd: "echo $ESPANSO_ONE$(echo $ESPANSO_TWO | tr [A-Z] [a-z])$ESPANSO_THREE"
shell: bash |
@chrisgrieser How are you getting around the 30-character limitation mentioned in the docs?
Edit: |
I don't, as you can see, the regex trigger in my snippet is only 3 characters long 😄 |
Hi,
It would be cool to use regular expression for trigger, something like this:
Thanks for an awesome project :)
The text was updated successfully, but these errors were encountered: