# Check for two strings

**URL:** <https://www.ruby-forum.com/t/check-for-two-strings/158917>\
**Category:** Ruby\
**Created:** [January 29, 2009, 12:53pm UTC](https://www.ruby-forum.com/t/check-for-two-strings/158917 "2009-01-29T12:53:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 29, 2009, 12:53pm UTC](https://www.ruby-forum.com/t/check-for-two-strings/158917/1 "2009-01-29T12:53:34Z")

</div>

Is this possible to check for two strings.  
i want to check whether these two params exits i want to proceed the  
process  
i get two strings through form  
search\_string\_1 = params[:first\_name]  
search \_string\_2 = params[:second\_name]  
if folder\_name.include?(search\_string\_1)(search\_string\_2)

end

Any helps pls

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 30, 2009, 4:19am UTC](https://www.ruby-forum.com/t/check-for-two-strings/158917/2 "2009-01-30T04:19:58Z")

</div>

i have tried your code.  
but it gives me argument error

[search\_string\_1,search\_string\_2].all? {|s| sub\_folder\_name.include? s}

pls help me  
Thanks

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 29, 2009, 1:09pm UTC](https://www.ruby-forum.com/t/check-for-two-strings/158917/3 "2009-01-29T13:09:32Z")

</div>

2009/1/29 Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Is this possible to check for two strings.  
> i want to check whether these two params exits i want to proceed the  
> process  
> i get two strings through form  
> search\_string\_1 = params[:first\_name]  
> search \_string\_2 = params[:second\_name]  
> if folder\_name.include?(search\_string\_1)(search\_string\_2)

What kind of test do you want? Do you want both or at least one of them?

[search\_string\_1,search\_string\_2].all? {|s| folder\_name.include? s}  
[search\_string\_1,search\_string\_2].any? {|s| folder\_name.include? s}

Cheers

robert
