Interactive ruby ready.
> time = /\A(?<hours>(0\d|1[0-9]|2[0-3])):(?<minutes>([1-5]\d|0\d))\Z/
=> /\A(?<hours>(0\d|1[0-9]|2[0-3])):(?<minutes>([1-5]\d|0\d))\Z/
> match = time.match '11:30'
=> #<TypeError: can't dump MatchData>
我正在尝试运行代码,但出现上述错误。我做错了什么regexp
帮助我改进它。
编辑
> time = /\A(0\d|1[0-9]|2[0-3]):([0-5]\d)\Z/
=> /\A(0\d|1[0-9??]|2[0-3])??:([0-5]\d)\Z/
> time.match('11:30')
=> #<TypeError: can't dump MatchData>
>