正则表达式在一个字符之后捕获一组单词但被另一个字符分隔

Regex to capture group of words after one character but separated by another

我正在尝试捕获由连字符 (-) 分隔的竖线字符 (|) 之后的所有子字符串。具体来说,我在寻找这些没有前后空格的词组:

  1. Status
  2. Bitmask Flag
  3. Another Bitmask Flag

来自以下字符串:

Controller | Status - Bitmask Flag - Another Bitmask Flag

您可以使用以下模式:

(?<=\| |- )[a-zA-Z ]+\b
  • (?<=\| |- ) \- 后跟空格的正面回顾。
  • [a-zA-Z]+ 字母字符,一个或多个
  • \b字边界。