Anand
Anand

Reputation: 21320

String value to replace using regex in Notepad++

I have Notepad++ text editor and have the SQL script file that has many INSERT statements, exported from a table. There is a column TIMESTAMP in every row with value like this to_timestamp('08-NOV-13 11.51.51.480570000 AM','DD-MON-RR HH.MI.SS.FF AM').

I need to create a script and replace the above value with current_timestamp so all to_timestamp('08-NOV-13 11.51.51.480570000 AM','DD-MON-RR HH.MI.SS.FF AM') like values will be replaced with current_timestamp.

Also, let me know if there is any online site available to do do this conversion.

Upvotes: 0

Views: 229

Answers (2)

Johnny
Johnny

Reputation: 491

I think Sublime Text is very ideal for your needs.

Open Sublime Text, copy your input onto the text area, press Ctrl+H, press Alt+R, and input the following pattern:

to_timestamp\([^)]+\)

in the "Find What" text box. Now enter "current_timestamp" (without quotes) in the "Replace with" text box, then press "Replace" or "Replace All" and it's done.

Upvotes: 1

MarcinJuraszek
MarcinJuraszek

Reputation: 125620

Following regex should match your to_timestamp() calls, try using it as find/replace pattern.

to_timestamp\('[0-9]{2}-[A-Z]{3}-[0-9]{2} (?:[0-9]{2}.){3}[0-9]{9} [AMP]{2}','DD-MON-RR HH.MI.SS.FF AM'\)

Upvotes: 0

Related Questions