I have a bunch of posts written in markdown and I need to remove the periods from the end of every paragraph in each of them
The end of a paragraph in markdown is delimited by:
- 2 or more
\n
s or - The end of the string
However, there are these edge cases
- Ellipses
- Acroynms (e.g., I don't want to drop the final period in "Notorious B.I.G." when it falls at the end of a paragraph). I think you can deal with this case by saying "don't remove the final period if it's preceded by a capital letter which is itself preceded by another period"
- Special cases:
e.g.
,i.e.
,etc.
Here's a regular expression that matches posts that have offending periods, but it doesn't account for (2) and (3) above:
/[^.]\.(\n{2,}|\z)/