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

1 Answer 1

2

You have an extra > in the style pattern:

pattern_str = '(?P<style>[^|]*)\|(?P<tags>[^|]*)'
Sign up to request clarification or add additional context in comments.

2 Comments

@sashimi: You're welcome; and hey, a typo happens to everyone ;)
@sashimi - this is the part where you click the checkmark to mark this as the answer to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.