Reputation: 51
I am struggling to figure out how to replace date format in notepad++ I have a key which contain different dates.
<pk2>2014/01/03</pk2>
Should be changed to:
<pk2>2014-01-03</pk2>
and so on.
Any suggestion on how to do this?
Upvotes: 2
Views: 507
Reputation: 91508
This will replace /
with -
only inside tag <pk2>...</pk2>
.
Tell me if you want to replace other dates.
(?:<pk2>|\G(?!^))\d+\K/(?=.*</pk2)
-
. matches newline
Explanation:
(?: # non capture group
<pk2> # opening tag pk2
| # OR
\G(?!^) # restart from last match position if not beginning of line
) # end group
\d+ # 1 or more digits
\K # forget all we have seen until this position
/ # a slash
(?= # positive lookahead, make sure we have after:
.* # 0 or more any character but newline
</pk2 # closing tag
) # end lookahead
Screenshot (before):
Screenshot (after):
Upvotes: 2