find and replace with regular expressions



I am using regular expressions to search a string (always full
sentences, maybe more than one sentence) for common abbreviations and
remove the periods. I need to break the string into different
sentences but split('.') doesn't solve the whole problem because of
possible periods in the middle of a sentence.

So I have...

----------------

import re

middle_abbr = re.compile('[A-Za-z0-9]\.[A-Za-z0-9]\.')

# this will find abbreviations like e.g. or i.e. in the middle of a
sentence.
# then I want to remove the periods.

----------------

I want to keep the ie or eg but just take out the periods. Any
ideas? Of course newString = middle_abbr.sub('',txt) where txt is the
string will take out the entire abbreviation with the alphanumeric
characters included.
.



Relevant Pages

  • Re: how do i separate numbers and text in a cell?
    ... installation on Cognos (5.5 hrs) ... > Example l) EMW shipment PRORDF modifications (1 uur) ... because the numbers have descriptive text abbreviations after them. ... Function ExtractNumber(ByVal StringIn As String) As Single ...
    (microsoft.public.excel.misc)
  • Re: find and replace with regular expressions
    ... maybe more than one sentence) for common abbreviations and ...  Of course newString = middle_abbr.subwhere txt is the ... string will take out the entire abbreviation with the alphanumeric ... Capture the letters using parentheses: ...
    (comp.lang.python)
  • Re: Properly punctuating pauses in speech
    ... string of letters is read as a string of letters (e.g., ... But many true abbreviations never had a dot, eg Mr, Mrs, Miss and Dr. ...
    (rec.arts.sf.composition)
  • Re: find and replace with regular expressions
    ... maybe more than one sentence) for common abbreviations and ... string will take out the entire abbreviation with the alphanumeric ... U could try it with a statistical analysis; ...
    (comp.lang.python)
  • Re: Deformat in VB Excel - turn "Jan" into numeric
    ... Public Function GetMonth(Txt As String) As Integer ... abbreviations. ... There is a built-in MonthName function that already does this. ...
    (comp.lang.basic.visual.misc)