Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 956145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:29:56+00:00 2026-05-16T00:29:56+00:00

I have a bunch of posts written in markdown and I need to remove

  • 0

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 \ns or
  • The end of the string

However, there are these edge cases

  1. Ellipses
  2. 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”
  3. 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)/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:29:56+00:00Added an answer on May 16, 2026 at 12:29 am

    A Ruby 1.8.7 compatible algorithm:

    s = %{this is a paragraph.
    
    this ends with an ellipsis...
    
    this ends with etc.
    
    this ends with B.I.G.
    
    this ends with e.g.
    
    this should be replaced.
    
    this is end of text.}.strip
    
    a = s.split(/\n{2,}/).each do |paragraph|
      next unless paragraph.match /\.\Z/
      next if paragraph.match /(\.[a-zA-Z]|etc|\.\.)\.\Z/
      paragraph.chop!
    end.join("\n\n")
    
    >> puts a
    this is a paragraph
    
    this ends with an ellipsis...
    
    this ends with etc.
    
    this ends with B.I.G.
    
    this ends with e.g.
    
    this should be replaced
    
    this is end of text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have bunch of web document and want to remove the html tags from
I have a bunch of Users, each of whom has many Posts. Schema: Users:
I display a bunch of posts from users on a page. I have the
I have a bunch of posts stored in text files formatted in yaml/textile (from
I've seen a bunch of posts related to this, but none seem to have
I have a bunch of files that I need to be able to transport
I have a bunch of classes I want to rename. Some of them have
I've found a bunch of posts on this problem and have actually managed to
I have an asp page which takes a bunch of input and posts to
Let's say I have a bunch of posts and I want to know if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.