-1
  email = re.search('(.*?)-+(.*?)-+', line).group(1)
  password = re.search('(.*?)-+(.*?)-+', line).group(2)
  user_data.write("%s\t%s\n" % (email, password))

how to combine the first and second line into one line?

another question:

email = re.search("[a-zA-Z0-9.!#$%&'*+-/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*", line)

how should I split the line into two lines?

Facundo Casco
  • 10,065
  • 8
  • 42
  • 63
kuafu
  • 1,466
  • 5
  • 17
  • 28
  • 3
    If you want to ask another question, ask another question. Don't edit more questions into this one. – Gareth Latty Jun 16 '12 at 13:38
  • 3
    And yes, [the regex required to correctly parse an email address is incredibly complex](http://stackoverflow.com/questions/703060/valid-email-address-regular-expression). You are better off protecting against obvious user error and going from there. – Gareth Latty Jun 16 '12 at 13:39
  • ok,I know one post on question. – kuafu Jun 16 '12 at 13:49
  • 4
    @young001: Someone edited your question to correct your spelling and you edited it back? What does the word "combile" mean? – Joel Cornett Jun 16 '12 at 14:03
  • joel,when someone edit my question,I editing it the same time,and when I saved,it override editor's effort.:-( – kuafu Jun 16 '12 at 19:03

1 Answers1

3

You can use groups():

email, password = re.search('(.*?)-+(.*?)-+', line).groups()
sth
  • 222,467
  • 53
  • 283
  • 367