# Do i need a regex?

**URL:** <https://www.ruby-forum.com/t/do-i-need-a-regex/61412>\
**Category:** Ruby\
**Created:** [May 23, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/do-i-need-a-regex/61412 "2006-05-23T22:19:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [May 23, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/do-i-need-a-regex/61412/1 "2006-05-23T22:19:41Z")

</div>

i am trying to match the string “–(null)–” in ruby

i am doing this after reading a line

if line.match("–null–")  
#code here

its not working though

would i need a regex

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [May 23, 2006, 10:24pm UTC](https://www.ruby-forum.com/t/do-i-need-a-regex/61412/2 "2006-05-23T22:24:15Z")

</div>

On Wed, May 24, 2006 at 05:19:53AM +0900, newbie wrote:

> i am trying to match the string “–(null)–” in ruby
> 
> i am doing this after reading a line
> 
> if line.match("–null–")  
> #code here
> 
> its not working though
> 
> would i need a regex

You _could_ use a regex but you don’t _need_ to if all you care about is  
inclusion of that string.

if line.include?(’–null–’)

marcel

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [May 23, 2006, 11:13pm UTC](https://www.ruby-forum.com/t/do-i-need-a-regex/61412/3 "2006-05-23T23:13:35Z")

</div>

> > would i need a regex
> 
> You _could_ use a regex but you don’t _need_ to if all you care about is  
> inclusion of that string.
> 
> if line.include?(’–null–’)
> 
> marcel

marcel that worked perfectly

thank you very much! 🙂

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [May 24, 2006, 4:57pm UTC](https://www.ruby-forum.com/t/do-i-need-a-regex/61412/4 "2006-05-24T16:57:40Z")

</div>

> > marcel that worked perfectly
> 
> I’m surprised: in your original posting you mentioned the string  
> “–(null)–” which is somewhat different from “–null–”…
> 
> robert

i typed mine in with the parentheses

---

<div class="post-metadata">

**Author:** ![newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@newbie](https://www.ruby-forum.com/u/newbie)\
**Post date:** [May 24, 2006, 11:32am UTC](https://www.ruby-forum.com/t/do-i-need-a-regex/61412/5 "2006-05-24T11:32:29Z")

</div>

2006/5/23, newbie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > would i need a regex
> > 
> > You _could_ use a regex but you don’t _need_ to if all you care about is  
> > inclusion of that string.
> > 
> > if line.include?(‘–null–’)
> > 
> > marcel
> 
> marcel that worked perfectly

I’m surprised: in your original posting you mentioned the string  
“–(null)–” which is somewhat different from “–null–”…

robert
