Regex: match string at word end

I'm attempting this regex in a typed string trigger:

(?<![esuSliaoi ])ign$

but the $ that is supposed to designate a match at end of string isn't taking effect: this matches words like ignore. How to rewrite the above to match only at string/word end?

Word boundary is \b whereas $ is end-of-line (or in multiline mode, end-of-string).

At the time you hit the N key that is the end of the string -- KM doesn't know you are going to continue typing. There's an implicit \z at the end of the string.

Also, \b won't work in a typed string trigger regex, since that implicit \z is a word boundary... See the Typed String Trigger page for more.

I'm not sure how well a negative lookbehind is going to work, either.

Perhaps if you explained what you are trying to achieve?

1 Like

Hi, I'm trying to replace a typo: when typing a word ending in ign I want the text editor to replace it with ing. I use Sublime and haven't found auto text substitution within that application so was hoping to do that with KM.

I assume you don't have to regularly request that someone "align a sign", then... :wink:

Since you can't use a trailing word boundary in a typed string trigger you'll need to come up with your own rule for the "next character typed". Something like "ign followed by not a lowercase letter", capturing the last character and appending it to your corrected ing would be a good start:

ign to ing test.kmmacros (2.1 KB)