ruby - Remove periods from the end of markdown paragraphs -


I have a bunch of posts written in Markdown and I need to take time from the end of each paragraph of them < / P>

  • The end of the string
  • However, these side cases are

    1. oval
    2. Acroynms (eg ., I do not want to leave the last time in "infamous Big" when it falls at the end of the paragraph). I think that you can say in this matter that do not take the last period, if it happens before the capital letter which is already there before another period "
    3. Special cases: Like , i.e. , etc.

    Here is a regular expression that matches

    / [^.] \. (\ N {2,} | \ z) /

      (? & Lt ;! \. [A-zA-Z] | etc. \.) \. (? =? \) { Z] | etc. \. \.).  - Note to ensure that the term . ,  etc. ,  ..  (for elipesis).  
  • . .
  • (? = \ N {2,} | \ Z) < S = "" "ths

    Test:

      s =" "A paragraph. It ends with a loneliness ... Ends with etc. etc. ends with BIG This example ends with this should be changed It is the end of the text. "" Print s.gsub (/ (?? Lt;! \ [A-zA-Z] | etc | \. \) \. (? = [\ N] {2,} Output:  
      This is a paragraph that ends with an oval ... it ends with etc. It ends with the Big, with example it ends, it should change  

  • Comments