Compile word

def compile_word(word):
	if word.isupper():
		terms = [('%s*%s' % (10**i, d))
			for (i, d) in enumerate(word[::-1])]
		return '(' + '+'.join(terms) + ')'
	else:
		return word

Regular Expression
->find substring string

ex. s = ‘some long thing with words’
s.find(‘word’)

‘baa*!’

* a*
? a?
. a.

def search(pattern, text):
	if pattern.startswitch('^'):
		return match(pattern[l:], text)
	else:
		return match('.*' + pattern, text)

def match(pattern, text):
	if pattern == '':
		return True
	elif pattern == '$':
		return (text == '')
	elif len(pattern) > 1 and pattern[1] in '*?':

	else:
		return (match1(pattern[0], text) and
		match(pattern[1:], text[1:]))