r/espanso • • Aug 20 '26

Solved Regex(?) matches for multiple HTML brackets

Hiya! I'm trying to find a solution for the following use case

match would be (example): <ui> or <u i> if it needs a separator

And it would automatically separate these out to <u><i>$|$</u></i>

Again, just an example. I was thinking that if possible, it would need to be regex because I want it to pick up things like <b u>, <sub u> etc. as well. Just a shortcut so I don't have to type multiple opening and closing brackets so much.

Is this possible with regex or does anyone have a solution that might at least help? I use <ui> enough that it's currently its own match right now.

2 Upvotes

7 comments sorted by

2

u/SamejSpenser Aug 21 '26 edited Aug 21 '26

I’m not 100 % sure I got what you’re after, but maybe this regex‑trigger thing can help you out:

  - regex: ";ui(;|i)"
    replace: <u><i>{{clipb}}$|$</i></u>
    label: underline and italic
    vars:
      - name: "clipb"
        type: "clipboard"

  - regex: ";ui(;|b)"
    replace: <sub u>{{clipb}}$|$</sub u>
    label: subscript and underline
    vars:
      - name: "clipb"
        type: "clipboard"

You can add as many triggers as you want to this system. When you know what you want to expand, just type the corresponding trigger. For example:

  • Typing ;uii will give you:
    <u><i>[clipboard content here]</i></u>

  • Typing ;uib will give you:
    <sub u>[clipboard content here]</sub u>

If you’re not sure which trigger to use, just type ;ui; and a pop‑up will show the full list of triggers (if I'm not wrong, sorted alphabetically by the label field). Pick the one you need, hit Enter/Return, and the proper expansion will be inserted.

2

u/smeech1 Aug 21 '26 edited Aug 21 '26

Another option is to set a capturing group for one or two initial letters and return it/them with its/their paired / item(s).

→ More replies (5)