28 lines
901 B
Python
28 lines
901 B
Python
import re
|
|
|
|
# meta regexes
|
|
meta_chars = re.compile(r'([\.\^\$\*\+\?\{\}\(\)\[\]\|\\])')
|
|
|
|
# shell
|
|
shell_command = re.compile(r'^[^ ]+')
|
|
|
|
# whitespace regexes
|
|
leading_whitespace = re.compile('^ *')
|
|
trailing_whitespace = re.compile(' *$')
|
|
whitespace = re.compile('^ *$')
|
|
|
|
# word regexes
|
|
word = re.compile('^[A-Za-z0-9_]+$')
|
|
word_char = re.compile('^[A-Za-z0-9_]$')
|
|
|
|
# perl regexes
|
|
perl_base = re.compile("^sub ")
|
|
perl_hash_cleanup = re.compile(r"^( *)([^ ]+|'(?:\.|[^'\'])*'|\"(?:\.|[^\\\"]*)\")( *)(=>)( *)([^ ].*)$")
|
|
perl_assign_cleanup = re.compile(r"^( *)((?:my |our )?[^ ]+)( *)(=(?!>))( *)([^ ].*)$")
|
|
perl_function = re.compile(r"^ *sub ([A-Za-z_][A-Za-z0-9_]*)")
|
|
|
|
# python regexes
|
|
python_base = re.compile(r"^[^ ]")
|
|
python_dict_cleanup = re.compile(r"^( *)((?:[^'\":]|'(?:\.|[^\'])*'|\"(?:\.|[^\'])*)+?)( *)(:)( *)([^ ].*)$")
|
|
python_assign_cleanup = re.compile(r"^( *)([^ ]+)( *)(=)( *)([^ ].*)$")
|