s = "GE.O A SSSS !@# world E A A D a9e DX.X you"r = /(?-i)(?<=\s|^)[A-Z]{1,4}(\.[A-Z]{1,2})?(?=\s|$)/ if s =~ r matches = s.to_enum(:scan, r).map { Regexp.last_match } puts matches puts matches.to_s puts matches.length puts matches.kind_of?(Array) puts matches.include?("A")end
Standard input is empty
GE.O A SSSS E A A D DX.X [#<MatchData "GE.O" 1:".O">, #<MatchData "A" 1:nil>, #<MatchData "SSSS" 1:nil>, #<MatchData "E" 1:nil>, #<MatchData "A" 1:nil>, #<MatchData "A" 1:nil>, #<MatchData "D" 1:nil>, #<MatchData "DX.X" 1:".X">] 8 true false
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!