How do I delete a trailing period (.) followed by a number (one or two digits in length) directly preceding it? Example:
z <- c("awe", "p.56.red.45", "ted.5", "you.88.tom")
I only want to remove the .45 and the .5.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You just need a simple regular expression:
A few comments:
$character looks for the pattern at the end of the string[0-9]*looks for 1 or more digits. Alternatively, you could use\\d*or[[:digit:]]*.\\.matches the full stop. We need to escape the full stop with two slashes.