0

Here is my code:

import re

pattern_str = '(?P<style>[^|]*>)\|(?P<tags>[^|]*)'

p = re.compile(pattern_str)

m = p.match('OL|AAAAA')
a = m.group('style')  # AttributeError: 'NoneType' object has no attribute 'group'
print a

It doesn't work, how to fix it?

My python version is 2.6.5

chrki
  • 5,936
  • 6
  • 31
  • 53
sashimi
  • 723
  • 2
  • 8
  • 14

1 Answers1

2

You have an extra > in the style pattern:

pattern_str = '(?P<style>[^|]*)\|(?P<tags>[^|]*)'
João Silva
  • 85,475
  • 27
  • 147
  • 152