pmacs3/regex.py

22 lines
778 B
Python

import re
# 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("^( *)([^ ]+|'(?:\\.|[^'\\'])*'|\"(?:\\.|[^\\\"]*)\")( *)(=>)( *)([^ ].*)$")
perl_assign_cleanup = re.compile("^( *)((?:my |our )?[^ ]+)( *)(=(?!>))( *)([^ ].*)$")
perl_function = re.compile("^ *sub ([A-Za-z_][A-Za-z0-9_]*)")
# python regexes
python_base = re.compile("^[^ ]")
python_dict_cleanup = re.compile("^( *)((?:[^'\":]|'(?:\\.|[^\\'])*'|\"(?:\\.|[^\\'])*)+?)( *)(:)( *)([^ ].*)$")
python_assign_cleanup = re.compile("^( *)([^ ]+)( *)(=)( *)([^ ].*)$")