sub("^(.).*(\\d).*$", "\\1\\2", "ABCD some random words and spaces 1234")
Standard input is empty
[1] "A4"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!