If you want to remove characters only from the beginning and end, you can use the method string.strip(). This will give the following code:
>>> s1 = '== foo bar =='
>>> s1.strip('=')
' foo bar '
>>> s2 = '* foo bar'
>>> s2.lstrip('*')
' foo bar'
strip , , ltrip , rstrip .
, :
clean = re.sub(r'(^={2,})|(={2,}$)', '', clean)
clean = re.sub(r'^\*+', '', clean)
IMHO, strip/lstrip/rstrip, , .
: , , :
clean = clean.lstrip('*').strip('= ')
( , , , - , , .strip('= ') "=" "" , "=".)