user2272260 user2272260 - 7 months ago 13
Ruby Question

Ruby : find/scan/search a string in a sentence in

I am trying to find a string in a sentence

/a.**117228558440230**.24692.116944575135295/65456


want the string after
a
and before first
.
in ruby on rails

thanks in advance

Answer

You can do that with a simple regexp:

 string = '/a.117228558440230.24692.116944575135295/65456'

 regexp = /\D\.(\d*)\./
 regexp.match(string)[1]
 #=> "117228558440230"
Comments