What is the difference between the floowing regexes:
HEAD|GET, (HEAD|POST) & [HEAD|POST]?
Basically, I want to extract the number after either HEAD or POST.
irb(main):001:0> "This is HEAD and a POST".match("HEAD|POST")
=> #<MatchData "HEAD">
irb(main):002:0> "This is HEAD and a POST".match("(HEAD|POST)")
=> #<MatchData "HEAD" 1:"HEAD">
irb(main):003:0> "This is HEAD and a POST".match("[HEAD|POST]")
=> #<MatchData "T">
irb(main):004:0> "This is HEAD 1 and a POST 2".match("[HEAD|POST] (.)")
=> #<MatchData "D 1" 1:"1">
irb(main):005:0>
The last regex didn't match the "2" that is after "POST". Why? Also, why is "D 1" being matched?