# Re: How do I strip off the extra double quote or white space

**URL:** <https://www.ruby-forum.com/t/re-how-do-i-strip-off-the-extra-double-quote-or-white-space/66200>\
**Category:** Ruby\
**Created:** [August 23, 2006, 10:40pm UTC](https://www.ruby-forum.com/t/re-how-do-i-strip-off-the-extra-double-quote-or-white-space/66200 "2006-08-23T22:40:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ban\_Hoang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@Ban\_Hoang](https://www.ruby-forum.com/u/Ban_Hoang)\
**Post date:** [August 23, 2006, 10:40pm UTC](https://www.ruby-forum.com/t/re-how-do-i-strip-off-the-extra-double-quote-or-white-space/66200/1 "2006-08-23T22:40:34Z")

</div>

Thanks for your help, Ben!

I am confused on your assert\_equal method:

assert\_equal a.gsub(/[’"]/, ‘’), b.gsub(/[’"]/, ‘’)

Is /[’"]/ will strip out the quotes when comparing?

My assert\_equal method:

assert\_equal(arr[0],$ie.frame(“top”).select\_list(:name,“site\_id”).getAll  
Contents)

1. The portion arr[0] is from the read in external file.
2. $ie.frame(“top”).select\_list(:name,“site\_id”). is from the dropdown  
list application  
=======================================

This is the csv external file dropList.csv contain:

:: Select Site :: !!Eastgate\_Mall

* * *

I think my actual problem is when reading into an array and compare, it  
did not separate :: Select Site :: as one field and ::  
!!Eastgate\_Mall to another field for double quotes

That why the expect is \<[":: Select Site ::,!!Eastgate\_Mall,\n"]  
( missing separate double quotes)

Instead of \<[":: Select Site ::", “!!Eastgate\_Mall”]\>.

* * *

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Ban\_Hoang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@Ban\_Hoang](https://www.ruby-forum.com/u/Ban_Hoang)\
**Post date:** [August 24, 2006, 6:02pm UTC](https://www.ruby-forum.com/t/re-how-do-i-strip-off-the-extra-double-quote-or-white-space/66200/2 "2006-08-24T18:02:25Z")

</div>

On Thu, Aug 24, 2006, Ban Hoang wrote:

> Thanks for your help, Ben!
> 
> I am confused on your assert\_equal method:
> 
> assert\_equal a.gsub(/[’"]/, ‘’), b.gsub(/[’"]/, ‘’)
> 
> Is /[’"]/ will strip out the quotes when comparing?

Notice that that call to assert\_equal is wrapped inside a method. So  
you would call

assert\_equal\_without\_quotes( arr[0], $ie.frame… )

I think the real problem is that you need to figure out how to parse  
your file, though. You call it a csv but it’s not. My suggestion would  
be to fix it so it is 🙂

> I think my actual problem is when reading into an array and compare, it  
> did not separate :: Select Site :: as one field and ::  
> !!Eastgate\_Mall to another field for double quotes

Correct.

> That why the expect is \<[":: Select Site ::,!!Eastgate\_Mall,\n"]  
> ( missing separate double quotes)

Not only is it missing the quotes, but it’s adding it as a single  
element instead of two, as you want.

If your file looks like this:

* * *

## :: Select Site :: !!Something :: Select Site :: !!Something else …

Then you’ll need to determine how to parse that. Quick, dirty, and  
untested:

* * *

contents = []

File.readlines(‘yourfile’).each do |line|  
line =~ /(:: ._? ::)\s+(!!._?)/

label = $1  
value = $2

## contents \<\< [$1, $2] end

There’s probably a better regex you could use, but the bottom line is,  
you need to extract the values from your file instead of just grabbing  
each line.

Again, it’s probably easiest to just make it a real csv file 🙂

Good luck!  
Ben
