Regex Question

Discussion in 'Python' started by Thomas =?ISO-8859-15?Q?G=FCttler?=, Aug 20, 2003.

  1. Hi!

    I want to parse a file that looks like this:

    a0001: basbasdb
    asbddsb
    asdbasdb
    abasbd
    a0002: fffff
    ffff
    ffffff
    ffff

    a???? should be the key and the following lines should
    be the value of a dictionary.

    My solution looks like this:

    regex=re.compile(r'(?:^|\n)(\w\d\d\d\d):((?:.(?!\n\w\d\d\d\d:))*)',
    re.DOTALL)
    matches=regex.findall(content)
    for match in matches:
    print match

    I think there is a better solution than this, don't you?

    thomas
     
    Thomas =?ISO-8859-15?Q?G=FCttler?=, Aug 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    716
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,639
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    607
  4. Xah Lee
    Replies:
    1
    Views:
    949
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    780
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page