I am not shure what do you want to do.

1) If you want to see if a string contains another string you can do it like
this:

'test                           ' =~ /test/

2) if you want to delete spaces from the end of the string you can do it
like this:

'test                           '.rstrip

or like this

'test                           '.delete(' ')

Zeljko

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Gargan
Sent: Wednesday, October 19, 2005 12:40 PM
To: wtrList (E-mail)
Subject: [Wtr-general] String matching

Hi folks,

        I'm reading a value from a textArea using text_field however all the
whitespace after the value is 
included i.e. I'm getting back a string like
"test                                                   "
I'm trying to match a preset value "test" to this but I can't get the string
matches method to work?

I've tried 
str1= "test                                                     "
str2 = "test"

str1.matches("^"+str2+" *$)

but it doesn't seem to match. My regexp isn't as strong as it could be but
I'd appreciate any help.

Perhaps there's some sort of trim function available? 

Thanks,
Mark.

Mark Gargan             
Software Developer
Allfinanz Distribution Software
<<http://www.allfinanz.com/>>
Direct Line: 213 5115
Fax: +353 1 295 2554 
<<mailto:[EMAIL PROTECTED]>>


_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to