Regular Expressions Using lookbehind to test endings


Example

A lookbehind can be used at the end of a pattern to ensure it ends or not in a certain way.

([a-z ]+|[A-Z ]+)(?<! ) matches sequences of only lowercase or only uppercase words while excluding trailing whitespace.