Help to identify medium letters for swash feature

Hi all, i am trying to understand how to add complex swashes to a font. I have for all letters this structure: a.init, a.medi a.fina and my swsh feature looks like this:

sub a’space by a.fina;
sub a by a.init;

but I need to identify a letter when it is between other letters to call all .medi


The following character after the end of a word is not necessarily space; it can be hyphen, quotation, number, line break, emoji, just about anything. What you need to do is to turn all letters to medial form first, and later check if a medial letter is preceded or followed by another medial. Depending on the condition, it needs to 1. remain the same, 2. get replaced with initial, 3. with final, and 4. with isolated (optional). You need to use multiple lookups to achieve this. See the tutorial: