You can use str.replace()
:
>>> course_name = "Post Graduate Certificate Programme in Retail Management (PGCPRM) (Online)"
>>> course_name.replace('(PGCPRM) ','')
'Post Graduate Certificate Programme in Retail Management (Online)'
edit: if you want to replace the word before (Online)
you need regex and a positive look-behind:
>>> re.sub(r'(\(\w+\) )(?=\(Online\))','',course_name)
'Post Graduate Certificate Programme in Retail Management (Online)'
Or if you want to remove the first parentheses use following :
>>> re.sub(r'(\(\w+\) ).*?','',course_name)
'Post Graduate Certificate Programme in Retail Management (Online)'
and for extract it use re.search
:
>>> re.search(r'(\(.*?\))',course_name).group(0)
'(PGCPRM)'