I am trying to replace a pattern in each row of my dataset with a single space.
The pattern is: MM/DD/YYYY ##:##:## Person Name (PNAME)
Each row is a string like:
[1] TEXT BEFORE... 04/17/2014 08:46:42 John Doe (JDOE) ...TEXT AFTER
Desired results:
[1] TEXT BEFORE... ...TEXT AFTER
I attempted it with the following (and many variations):
pattern <- "[[0-9]][[0-9]][[:punct:]][[0-9]][[0-9]][[:punct:]][[0-9]][[0-9]][[0-9]][[0-9]][[:space:]][[0-9]][[0-9]][[:punct:]][[0-9]][[0-9]][[:punct:]][[0-9]][[0-9]][[:space:]][[:alpha::]][[:space:]][[:alpha::]][[:punct:]][[:alpha::]][[:punct:]]) "
replacement <- " "
sub(pattern, replacement, data$Description)
It seems I am not setting the pattern correctly. I have read a number or regex questions on here but none that uses a pattern attempting to replace more than a single character/word. How would you write this?