def no_re_matches(re_pattern, length=5, max_attempts = 100):
for count in range(max_attempts):
try_string = ''.join(random.choice(string.ascii_letters) for x in range(length))
if re_search_better(re_pattern, try_string) is None:
return try_string
raise ValueUnitsError('Non-matching pattern cannot be found')
# abstracts the sub-formula contained in parentheses to a unique variable name
# if there are any variables already in formula they need to be selected by the re pattern variables_re so that duplicate variable names are not created
# returns the formula with all the new variables in it and a dictionary with the new variables as keys and the origional expression as the values
评论列表
文章目录