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
  • 6,143
  • 6
  • 35
  • 55
sashimi
  • 793
  • 2
  • 8
  • 14

1 Answers1

2

You have an extra > in the style pattern:

pattern_str = '(?P<style>[^|]*)\|(?P<tags>[^|]*)'
João Silva
  • 89,303
  • 29
  • 152
  • 158