# Validating multiple contents

**URL:** <https://www.ruby-forum.com/t/validating-multiple-contents/151131>\
**Category:** Ruby\
**Created:** [October 17, 2008, 7:15am UTC](https://www.ruby-forum.com/t/validating-multiple-contents/151131 "2008-10-17T07:15:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![balavrscse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@balavrscse](https://www.ruby-forum.com/u/balavrscse)\
**Post date:** [October 17, 2008, 7:15am UTC](https://www.ruby-forum.com/t/validating-multiple-contents/151131/1 "2008-10-17T07:15:47Z")

</div>

Hi  
If we want to validate result page with single text content we will  
use

```
 ie.text.include?(" Particular content ")

suppose if i want to validate page with multiple content like

                German rails
                NGINX

```

how to use ruby for this validation?

---

<div class="post-metadata">

**Author:** ![balavrscse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@balavrscse](https://www.ruby-forum.com/u/balavrscse)\
**Post date:** [October 17, 2008, 8:17am UTC](https://www.ruby-forum.com/t/validating-multiple-contents/151131/2 "2008-10-17T08:17:30Z")

</div>

Bala Krishnan wrote:

> Hi  
> If we want to validate result page with single text content we will  
> use
> 
> ```
> ie.text.include?(" Particular content ")
> 
> suppose if i want to validate page with multiple content like
> 
> German rails
> NGINX
> 
> ```
> 
> how to use ruby for this validation?

maybe something like  
ie.text.include?(" Particular content ") || ie.text.include?(‘ich  
bien’) ?

---

<div class="post-metadata">

**Author:** ![balavrscse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@balavrscse](https://www.ruby-forum.com/u/balavrscse)\
**Post date:** [October 17, 2008, 3:51pm UTC](https://www.ruby-forum.com/t/validating-multiple-contents/151131/3 "2008-10-17T15:51:24Z")

</div>

On Oct 17, 2008, at 12:15 AM, Bala Krishnan wrote:

> how to use ruby for this validation?  
> [“German rails”, “NGINX”].any? { |str| ie.text.include?(str) }

This will return true if any of the strings are found in ie.text.  
Replace any? with all? to return true only if all of the strings are  
found.

---

<div class="post-metadata">

**Author:** ![balavrscse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@balavrscse](https://www.ruby-forum.com/u/balavrscse)\
**Post date:** [October 18, 2008, 10:32am UTC](https://www.ruby-forum.com/t/validating-multiple-contents/151131/4 "2008-10-18T10:32:15Z")

</div>

On Fri, Oct 17, 2008 at 3:50 PM, Matthew M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ```
> > German rails
> > NGINX
> > 
> > ```
> > 
> > how to use ruby for this validation?
> 
> [“German rails”, “NGINX”].any? { |str| ie.text.include?(str) }
> 
> This will return true if any of the strings are found in ie.text. Replace  
> any? with all? to return true only if all of the strings are found.

More obscure but kind of cute:

Regexp.union(“German rails”, “NGINX”).match(ie.text)

Regexp.union creates a regexp that matches any of the parts. They’re  
regexp-escaped, too.
