[Solved] Extract only first match using python regular expression [duplicate]


Pretty simple:

In [8]: course_name
Out[8]: 'Post Graduate Certificate Programme in Retail Management (PGCPRM) (Online)'

In [9]: print re.sub('\([A-Z]+\)\s*', '', course_name)
Post Graduate Certificate Programme in Retail Management (Online)

In [17]: print re.search('\(([A-Z]+)\)\s*', course_name).groups()[0]
PGCPRM

0

solved Extract only first match using python regular expression [duplicate]