# Text comparision

**URL:** <https://www.ruby-forum.com/t/text-comparision/144425>\
**Category:** Ruby\
**Created:** [July 29, 2008, 4:05pm UTC](https://www.ruby-forum.com/t/text-comparision/144425 "2008-07-29T16:05:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthicg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@karthicg](https://www.ruby-forum.com/u/karthicg)\
**Post date:** [July 29, 2008, 4:05pm UTC](https://www.ruby-forum.com/t/text-comparision/144425/1 "2008-07-29T16:05:24Z")

</div>

hi,

i need to check the text “Test” from a dropdown list that contains more  
than 100 char.  
i have taken the text from dropdown list and store it in a variable a.(i  
dont know is it correct or not)  
that is if i execute “puts a” statement then it shows “abcd efg hij Test  
klmno pqrs tuvw xyz” .

now i need to check the text “Test” from variable a.  
i have tried,

b=“Test”  
if a== %b%

and is no luck.

could anybody know how to perform this task?

---

<div class="post-metadata">

**Author:** ![karthicg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@karthicg](https://www.ruby-forum.com/u/karthicg)\
**Post date:** [July 29, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/text-comparision/144425/2 "2008-07-29T16:13:21Z")

</div>

2008/7/29 Karthic G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> now i need to check the text “Test” from variable a.  
> i have tried,
> 
> b=“Test”  
> if a== %b%
> 
> and is no luck.
> 
> could anybody know how to perform this task?

Try using a regular expression:  
b = /Test/  
if b =~ a  
# Do stuff  
end

Farrel
