2012/10/14 Erez Ben shoham <[email protected]> > Hi > I have a string > str = "file name_Width34.56_Height45.97_.jpg" > > what is the best way to extract the the data from the string? > > file name => "file name.jpg" > width => "34.56" > hieght => "45.97" > > -- > Posted via http://www.ruby-forum.com/. > > string = "file name_Width34.56_Height45.97_.jpg" string =~ /(.+)_Width(\d+.\d+)_Height(\d+.\d+)_.jpg/ puts $1, $2, $3
http://rubular.com is your friend, try it. -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
