<human>:  Replace a substring when it is a separate word
<bot>: Here is some code to replace a separate word 'H3' by 'H1' in a string 'text'

re.sub('\\bH3\\b', 'H1', text)

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.