You need to make .* non-greedy: /video\[(.*)\]/.match "video[10]]]]" #=> #<MatchData "video[10]]]]" 1:[10]]]">.
0
r = /
\b # match a word break
video\[ # match string
(\d+) # match >= 1 digits in capture group 1
\] # match char
/x # extended/free-spacing mode
"Martha, where did you put video[10]?"[r,1]
#=> "10"
/video\[(.*?)\]/.match("video[10]")[1]gives"10").