File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import six
55
6- import regex as re
7- upper_re_s = r'\p{Lu}'
8- regex_snippets = {
9- 'acr' : r'\p{Lu}\p{Nd}' ,
10- 'abr' : r'\p{Lu}' ,
11- 'nab' : r'\p{Ll}' ,
12- 'wrd' : r'(?:\p{L}|\p{M}|\p{N}|\p{Pc})' ,
13- 'cur' : r'\p{Sc}' ,
14- 'digit' : r'\p{N}' ,
15- 'space' : r'(?:\p{Zs}|\v)' ,
16- 'char' : r'(?:[^\p{Zs}\v])' ,
17- }
6+ try :
7+ # Use regex module for matching uppercase characters if installed,
8+ # otherwise fall back to finding all the uppercase chars in a loop.
9+ import regex as re
10+ upper_re_s = r'\p{Lu}'
11+ regex_snippets = {
12+ 'acr' : r'\p{Lu}\p{Nd}' ,
13+ 'abr' : r'\p{Lu}' ,
14+ 'nab' : r'\p{Ll}' ,
15+ 'wrd' : r'(?:\p{L}|\p{M}|\p{N}|\p{Pc})' ,
16+ 'cur' : r'\p{Sc}' ,
17+ 'digit' : r'\p{N}' ,
18+ 'space' : r'(?:\p{Zs}|\v)' ,
19+ 'char' : r'(?:[^\p{Zs}\v])' ,
20+ }
21+ except ImportError :
22+ import re
23+ from sys import maxunicode
24+ upper_re_s = "" .join (
25+ [six .unichr (c ) for c in six .moves .range (maxunicode ) if six .unichr (
26+ c ).isupper ()])
27+ regex_snippets = {
28+ 'acr' : r'{0}0-9' .format (upper_re_s ),
29+ 'abr' : r'{0}' .format (upper_re_s ),
30+ 'nab' : r'a-z' ,
31+ 'wrd' : r'\w' ,
32+ 'cur' : r'' ,
33+ 'digit' : r'\d' ,
34+ 'space' : r'(?:\s|\v)' ,
35+ 'char' : r'\S' ,
36+ }
1837
1938halign_re_s = r'(?:\<(?!>)|(?<!<)\>|\<\>|\=|[()]+(?! ))'
2039valign_re_s = r'[\-^~]'
You can’t perform that action at this time.
0 commit comments