Pep8 for long pattern
Serhiy Storchaka
storchaka at gmail.com
Tue Mar 27 10:37:33 EDT 2018
27.03.18 17:17, Ganesh Pal пише:
> How do I split the below regex , so that it fits within the character
> limit of 79 words
>
>
> pattern = [
> r'(?P<p_owner>([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
>
> r'(?P<a_owner>(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
> '.']
For example:
pattern = [
r'(?P<p_owner>('
r'[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:'
r':HEAD))',
r'(?P<a_owner>(owner:\s+'
r'[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:'
r':HEAD))',
'.']
Or just use fixed number repetition:
pattern = [
r'(?P<p_owner>((?:[0-9a-fA-F]+:){5}:HEAD))',
r'(?P<a_owner>(owner:\s+(?:[0-9a-fA-F]+:){5}:HEAD))',
'.']
More information about the Python-list
mailing list