1

I'm using this for iOS shortcuts, not sure what language that is.

I have text like this

Begin (random characters) a word (random characters) End

This is repeated multiple times.

Begin and End are always the start and finish of the string.

I'm wanting to match every Begin to End group of text that doesn't contain "a word" that I know.

Example:

Begin dghugcdfhnbcd foo sdfyhnvdsd End
Begin sdhhnvdsgg bar drykjbcds
End

Match the one that doesn't have foo.

I thought this was working but got feedback that it was not.

Begin((?!foo).)*End

Thank you for any help.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • The reason, your regex doesn't work is that the last 'End' is on a new line (. does not match a newline). You can use this instead: Begin((?!foo)[\s\S])*?End – Poul Bak Feb 24 '20 at 22:20

0 Answers0