1

I'm sure there's a really simple answer to this, but I can't find it!

In Keyboard Maestro, I'm trying to set the trigger as a regular expression of semicolon followed by one of a few characters, like this:

;[.,\s]

When I put it like that, it works, but I only want the trigger to fire when the semicolon is on its own (at the beginning of a sentence, or after a space). I would think this would do the trick:

\b;[,.\s]

...but when I put the boundary character in, it doesn't work. What am I doing wrong? Thanks!

(I should add that the boundary character works fine when followed by an alphanumeric character, so it seems to just be an issue with symbols)

1 Answers1

1

You should use the opposite construct as there is no word boundary between a space or start of string and a semi-colon:

\B;[,.\s]
^^

Here, \B is a non-word boundary that matches at all the locations where a word boundary does not match. In this specific case, ; will be matches only at the start of the string or if preceded with a non-word char (any char other than a letter/digit/_ and, depending on the regex library, other (very rare) chars that are consider "word" chars.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • @CaseOfTheMondays Glad it did, please also consider [upvoting the answer if it turned out useful for you](http://meta.stackexchange.com/questions/173399/how-to-upvote-on-stack-overflow) – Wiktor Stribiżew Nov 15 '17 at 17:25