Parsing text in Python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Desperado2006
    New Member
    • Jun 2007
    • 1

    Parsing text in Python

    Hello! I am newbee in Python, who knows how to parse such text

    â Mid From Subject Cat. Flags
    1 Cell Bills <savings@postsl ide.com>
    Get Cell Phone bills Paid for 1 Year ($1800 Value)
    2 Roxie Mckee <QXQGSOTBS@durh amunified.org>
    Bill Gates got one
    3 MakeoverYourHom e <cozy@traintree .com>
    Grab 1500 bucks to Pottery Barn - details inside
    4 Optimum Approvals <needmoney@styl etarget.com>
    $10,000 USD Credit Line  No Credit Check  Everyone is Approved

    into such strings [[1,2,3,4],[1,2,3,4]] where
    1 - Number
    2 - name
    3 - email
    4 - message header

    I am wondering how to use re module here.
    Please help me
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by Desperado2006
    Hello! I am newbee in Python, who knows how to parse such text




    into such strings [[1,2,3,4],[1,2,3,4]] where
    1 - Number
    2 - name
    3 - email
    4 - message header

    I am wondering how to use re module here.
    Please help me
    Yes, you will want to use the re module in order to parse such things. The module is quite simple to use, but first you must understand the Regular Expression language in order to write the regex to accomplish your task.

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by bartonc
      Yes, you will want to use the re module in order to parse such things. The module is quite simple to use, but first you must understand the Regular Expression language in order to write the regex to accomplish your task.
      Regular-Expression.info is a good place to start with that.

      Comment

      Working...