Change YYYY-MM-DD to YYYYMMDD everywhere in file
Posted
by
richardh
on Super User
See other posts from Super User
or by richardh
Published on 2011-02-13T04:51:46Z
Indexed on
2011/02/13
7:27 UTC
Read the original article
Hit count: 500
vim
|search-and-replace
I can't just delete all of the hyphens, because elsewhere they are used as minus signs. I can find these dates with [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}
but I can't figure out how to keep those three different digit wildcards in memory. My attempts end up replacing the dates with the search string (e.g., :%s/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/[0-9]\{4\}[0-9]\{2\}[0-9]\{2\}/g
).
Any ideas? If there's a command line solution, I'd love to learn that, too. Thanks!
© Super User or respective owner