Search code examples
regexbashshellsedosx-snow-leopard

Find and replace date/time in string


I have already made a regex which should work, but it doesn't work.

echo "FileName.17:09:2010 4.16.PM.720p.mp4" | sed -E 's/\d{2}:\d{2}:\d{4}\ (\d|\d{2})\.(\d{2}|\d)\.((AM)|(PM))//g'

Should output: FileName..720p.mp4

But instead outputs the same "FileName.17:09:2010 4.16.PM.720p.mp4".


Solution

  • Is \d a valid character class in sed? Try replacing it with [0-9] or [:digit:]. See re_format.