Find and replace with reordered date format in notepad++

后端 未结 4 1896
失恋的感觉
失恋的感觉 2021-01-31 04:16

I have a file with a few thousand rows to be added to a MySQL database. There are date values in the rows which are in the dd-mm-yyyy format but I need them to be in the yyyy-mm

4条回答
  •  借酒劲吻你
    2021-01-31 05:10

    Another robust pattern that works on ISO date format values like "2010-11-30T00:00:00.266Z "

    Capturing groups of various elements of an ISO date representation

    "(\d{4})-(\d{1,2})-(\d{1,2})T([0-2]\d):([0-5]\d):([0-5]\d)(?:.\d+)?Z?\s?"

    In total six groups are being captured in this pattern, seventh group in the end containing '?:' is non-capturing, meaning it does not keep any value recorded by the group, simply ignores them.

    The six groups we have captured have numbers based on positions such as \1 \2 \3... upto \6.

    Replacement pattern to change that date into Database supported date format mostly used in Oracle values like - "11/30/2010 00:00:00 AM"

    "\2/\3/\1 \4:\5:\6 AM"

    It works well with Notepad++ Good Luck!

提交回复
热议问题