gsub('.*?(\\d+)(?![^\\r\\n\\d]*\\d).*$', '\\1', 'Happy 2022 New 01 years!',perl=TRUE)
Standard input is empty
[1] "01"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!