I am working with tweets and I would like to have all the variations of aa aaaa aaah ahhh replaced by a single expression 'ah'. However, using my code I also replace the single 'a' and the 'and' which I don't want to change.
a = 'trying a aa aaaaaa aaaah and aaaahhh aaaaaaaahhh '
re.sub('a+h*','ah',a)
This way i get:
Current output: 'trying ah ah ah ah ahnd ah ah '
But what I want is:
Desired output: 'trying a ah ah ah and ah ah '