ruby on rails - Regex - Capturing a number if a match exists -
I'm looking to capture the number after the vspace
. How would you do it regex? Here is a sample string.
& lt; Img align = "left" alt = "dude its me" border = "10" height = "168" hspace = "30" vspace = "10" width = "130" />
then the end result will be 10
< Previous>
& gt; & Gt; S = '& lt; Img align = "left" alt = "dude its me" border = "10" height = "168" hspace = "30" vspace = "10" width = "130" /> & Gt; & Gt; /vspace="(\d+)"/.match(s)[1] = & gt; Or, if you are not sure whether this exists or not: if / vspace = "(\ d +)" / = ~ S puts $ 1 and puts "no match" end
Comments
Post a Comment