I want my string to only contain dash/alphabetic letter/number. I have converted all special characters to dash using
string %>%
gsub("[[:punct:]]", "-", .) %>%
gsub(" ", "-", .) %>%
gsub("\\-+", "-", .)
How to validate/remove last/first character(s) if they are not alphabetic/number in a string using regex?
Example input:
"-example-one111-" "-222example-two" "333example-333three333-"
Expected output:
"example-one111" "222example-two" "333example-333three333"