# String search

**URL:** <https://www.ruby-forum.com/t/string-search/107454>\
**Category:** Ruby\
**Created:** [June 21, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/string-search/107454 "2007-06-21T23:06:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [June 21, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/string-search/107454/1 "2007-06-21T23:06:46Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [June 21, 2007, 11:33pm UTC](https://www.ruby-forum.com/t/string-search/107454/2 "2007-06-21T23:33:49Z")

</div>

Jeffrey B. 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)))
