d.s d.s - 6 months ago 31
Python Question

Regex: How to extract a particular pattern individually from a text?

I am trying to extract a pattern using regular expression from a text shown bellow.

to_timestamp('02-04-09 00:00:00.000000000','RR-MM-DD HH24:MI:SS.FF'),'REP00061 ',to_timestamp('08-05-30 07:27:36.000000000','RR-MM-DD HH24:MI:SS.FF'),

How can I write a regex in Python to extract following patterns individually?

to_timestamp('02-04-09 00:00:00.000000000','RR-MM-DD HH24:MI:SS.FF')
to_timestamp('08-05-30 07:27:36.000000000','RR-MM-DD HH24:MI:SS.FF')


basically using pythex.org you can create your regex with ease.

for example :

m = re.findall(r'(to_timestamp\(\'.*?\',\'.*? .*?\'\))',str)

the findall in the re module will create a list of all the matches.