sa<-c("100 dollars for 200 pesos", "100 dollars 200 pesos")sub(".*dollars\\D*(\\d+).*", "\\1", sa)
Standard input is empty
[1] "200" "200"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!