s <- c('week 01st', 'weeks 02nd', 'year2022week01st', 'week 4th')gsub("weeks?\\h*\\K0+(?=[1-9]\\d*[a-zA-Z])", '', s, perl=T)
Standard input is empty
[1] "week 1st" "weeks 2nd" "year2022week1st" "week 4th"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!