I am looking to remove the non-numeric characters within a certain parentheses, and remove other parentheses in that line. Look below for an example;
text <- c("1110383 Project something 11/22/2019 (WSO) (89021-design)
John Doe (John.Doe@company22.com)",
"1110383 Project something 11/22/2019 ASP (890212-wso)
John Doe (John.Doe@company22.com)
Other Stuff",
"1110383 Project something SD (890212)
John Doe (John.Doe@company22.com)")
The expected output would be:
cat(paste0(myoutxt, collapse = "\n"))
# 1110383 Project something 11/22/2019 WSO (89021)
# John Doe (John.Doe@company22.com)
# 1110383 Project something 11/22/2019 ASP (890212)
# John Doe (John.Doe@company22.com)
# 1110383 Project something SD (890212)
# John Doe (John.Doe@company22.com)
I came up with a regex that matches my 5 or 6 digit number, but I am not sure what should be the replacement. Also I think the following should be modified since it doesn't consider possible presence of other parentheses to remove them.
^.*?\\([^\\d]*(\\d{5,6})[^\\d]*\\).*$
Logic:
Basically, I am looking to find the line with a 5-6 digit number (e.g. 89021 or 890212) between parentheses. Then, if there are other stuff within that parentheses, I want to remove them (e.g. -design or -wso). And lastly, if there are other parentheses in that specific line (e.g. (WSO)) I want the parentheses, and not the word, to be removed.