From: Brian Candler Date: 2012-09-03T16:44:49+09:00 Subject: Re: Extract # Number from a string Erez Ben shoham wrote in post #1074385: > Hi > > I have a string > how can i extract the number after the # sign? Use a reegular expression match. > old_string = "this is _ a 76string / #123 like 456" if old_string =~ /#([0-9]+)/ new_string = $1 else puts "Couldn't find it" end There are shortcuts, e.g. \d is the same as [0-9] Google for loads of regular expression tutorials on the Internet. Ruby is very similar, with some minor differences (e.g. to match start and end of string use \A and \z respectively) -- Posted via http://www.ruby-forum.com/.