RegEx Question for the Day - Dropping Last Character of Input

Here is my macro:

The output looks like this:

Screen Shot 2021-11-12 at 12.07.43 PM

For some reason it is dropping the last character. As I have tested it seems like something to do with the last name ending in s?

Thanks for any suggestions
Roger

It drop because the 2nd capturing group didn't include S.

Suggest you use regex101 to verify cause this regex site will explain what the regex is doing

Alternatively, with a space-delimited string like a multi-part name, Keyboard Maestro also allows you to reference the last word directly, without any need for a regular expression.

where:

  • the space between [-1] and % specifies the delimiting character (otherwise a comma, by default)
  • [-1] is the last item in the (one-based) index.

You can get the length of the array by using the [0] index:

5 Likes