Forum: Ruby string search

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7070c0ca59124b4d96dd27ea52ad359e?d=identicon&s=25 Jeffrey Bowen (Guest)
on 2007-06-21 23:06
(Received via mailing list)
@speed += 1 if sp.slice(8..13) == "03X16"

I've pulled bits 8 though 13 from my string and want
to see if it equal 03X16 where X is number 0-9.
Something like "grep -c 03.16 temp" would work.  I've
tried \d of course this did not work.

Thanks
Jeff
3afd3e5e05dc9310c89aa5762cc8dd1d?d=identicon&s=25 Tim Hunter (Guest)
on 2007-06-21 23:33
(Received via mailing list)
Jeffrey Bowen wrote:
> @speed += 1 if sp.slice(8..13) == "03X16"
>
> I've pulled bits 8 though 13 from my string and want
> to see if it equal 03X16 where X is number 0-9.
> Something like "grep -c 03.16 temp" would work.  I've
> tried \d of course this did not work.
>
>

@speed += 1 if (/03\d16/.match(sp.splice(8..13)))
This topic is locked and can not be replied to.