I am trying to replace 'hi' and 'hello' with 111 but get stuck with pandas.str.replace(). any suggestions? thanks!
a1 = pd.Series('12:04:25 Roberts: Hi, Hello, hi this hi')
## it will replace 'this' too using the re below
a1.str.replace('(hello|hi)', '111', regex=True, flags=re.IGNORECASE)
-- 12:04:25 Roberts: 111, 111, 111 t111s 111
## if I set '^hi$' then 'Hi' will be keeped
a1.str.replace('(hello|^hi$)', '111', regex=True, flags=re.IGNORECASE)
-- 12:04:25 Roberts: Hi, 111, hi this hi
## taking space and comma into consideration still the same
a1.str.replace('(hello|^\s?hi,?$)', '111', regex=True, flags=re.IGNORECASE)
-- 12:04:25 Roberts: Hi, 111, hi this hi