rx = /(?:\G(?!\A)|\A(?=(?:#\d\s*)*\z))\s*\K#\d/p "#1 #2".scan(rx)p "#1 NO #2".scan(rx)
Standard input is empty
["#1", "#2"] []
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!