re = /\[([^\].]*)\]:\W?(.*)/
str = '[12:17:05][econ]: cid=0 authed
[12:17:11][server]: player is ready. ClientID=0 addr=87.100.133.110:64762
[12:17:11][game]: Teams are balanced (red=1 blue=0)
[12:17:11][server]: player has entered the game. ClientID=0 addr=87.100.133.110:64762
[12:17:11][game]: team_join player=\'0:wavi\' team=0
[12:17:13][game]: pickup player=\'0:wavi\' item=3
[12:17:25][game]: pickup player=\'0:wavi\' item=2
[12:17:33][game]: flag_grab player=\'0:wavi\' team=0
[12:17:34][game]: pickup player=\'0:wavi\' item=1
[12:17:34][game]: pickup player=\'0:wavi\' item=1
[12:17:43][game]: pickup player=\'0:wavi\' item=0
[12:17:44][game]: flag_capture player=\'0:wavi\' team=0 time=11.38
[12:17:48][game]: kill killer=\'0:0:wavi\' victim=\'0:0:wavi\' weapon=-1 special=0
[12:17:52][server]: client dropped. cid=0 addr=87.100.133.110:64762 reason=\'\'
[12:17:52][game]: kill killer=\'0:0:wavi\' victim=\'0:0:wavi\' weapon=-3 special=0
[12:17:52][game]: leave player=\'0:wavi\'
[12:17:52][game]: Teams are balanced (red=0 blue=0)
[econ]: cid=0 authed
[server]: player is ready. ClientID=0 addr=87.100.133.110:64762
[game]: Teams are balanced (red=1 blue=0)
[server]: player has entered the game. ClientID=0 addr=87.100.133.110:64762
[game]: team_join player=\'0:wavi\' team=0
[game]: pickup player=\'0:wavi\' item=1
[game]: pickup player=\'0:wavi\' item=1
[game]: pickup player=\'0:wavi\' item=1
[game]: pickup player=\'0:wavi\' item=2
[game]: pickup player=\'0:wavi\' item=4
[game]: flag_grab player=\'0:wavi\'
[game]: pickup player=\'0:wavi\' item=2
[game]: pickup player=\'0:wavi\' item=0
[game]: pickup player=\'0:wavi\' item=3
[game]: flag_capture player=\'0:wavi\'
[game]: pickup player=\'0:wavi\' item=2
[game]: kill killer=\'0:wavi\' victim=\'0:wavi\' weapon=-1 special=0
[server]: client dropped. cid=0 addr=87.100.133.110:64762 reason=\'\'
[game]: leave player=\'0:wavi\'
[game]: Teams are balanced (red=0 blue=0)'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html