-2

I'm trying to use regex to remove a word that ends with a period.

I want to only remove Ep. as a whole word, but not if it's part of another word.

Also I will use RegexOptions.IgnoreCase.


This Ep. is 01. TestEp.01Test.

Should be:

This is 01. TestEp.01Test.


I thought it should be \b(Ep\.)\b but it doesn't work.

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


I have tried https://stackoverflow.com/a/5696940/6806643

Matt McManis
  • 4,475
  • 5
  • 38
  • 93

1 Answers1

0

It should be \b(Ep\.)\B, because the period is not a "word" character but a "non-word" character and as such, you need a "non-word boundary" (\B) and not a "word boundary" (\b).

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443