0

This regex he | she selects he or she (with one space before and after):

how he just he just
when she just she just

Can I exclude selection if a word how or when stands before? I mean select only second column in the example above.

https://regex101.com/r/pEGLD2/2

F. Vosnim
  • 476
  • 2
  • 8
  • 23
  • Usually, a negative lookbehind does this job. If you have trouble with that, please edit the question with your current regex. – Wiktor Stribiżew Mar 26 '20 at 12:18
  • `\w*(?<!how) he | she ` It's not selecting what I ask in the question. – F. Vosnim Mar 26 '20 at 12:21
  • Certainly, you do not have any word chars there, you do not need `\w*`. Besides, after `how` and `when` you havbe a space. You should account for that in the lookbehind. Also, if you want to apply one or a series of lookbehinds to two or more alternatives, group them. – Wiktor Stribiżew Mar 26 '20 at 12:23
  • 1
    Just an example: https://regex101.com/r/6faQIi/1 – Wiktor Stribiżew Mar 26 '20 at 12:24

0 Answers0