Created
January 28, 2013 21:42
-
-
Save FiXato/4659362 to your computer and use it in GitHub Desktop.
Something for Unknown_Entity aka o_o
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#encoding: utf-8 | |
msgs = [ | |
"[1-7] Porto Mojada: Foxtrot Tango [Work your alphabets]", | |
"[SOLVED: TATTOO] [1-9] Topless Beach: Boxstep [Gathering Data. Keyword: Boxing]", | |
"[SOLVED: SYLVESTER] [2-2] Video Store: Harold's Puzzle" | |
] | |
regexp = /(\[SOLVED: (?<solution>.+?)\] )?\[(?<num1>\d+)(-(?<num2>\d+))?\] (?<title>.+?)( \[(?<hint>.+?)\])?\z/ | |
msgs.each{|msg| puts msg.match(regexp).inspect} | |
#<MatchData "[1-7] Porto Mojada: Foxtrot Tango [Work your alphabets]" solution:nil num1:"1" num2:"7" title:"Porto Mojada: Foxtrot Tango" hint:"Work your alphabets"> | |
#<MatchData "[SOLVED: TATTOO] [1-9] Topless Beach: Boxstep [Gathering Data. Keyword: Boxing]" solution:"TATTOO" num1:"1" num2:"9" title:"Topless Beach: Boxstep" hint:"Gathering Data. Keyword: Boxing"> | |
#<MatchData "[SOLVED: SYLVESTER] [2-2] Video Store: Harold's Puzzle" solution:"SYLVESTER" num1:"2" num2:"2" title:"Video Store: Harold's Puzzle" hint:nil> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment