On 18-Jul-06, at 8:57 PM, Volkan Civelek wrote:

>
>
> arg1 = "(1)a"
> arg2 = "(1)a"
>
> if arg1.match(arg2)
> 	puts "Matched"
> else
> 	puts "Don't Matched"
> end
>
>
> gives me "Don't Matched" ??

That's because parentheses are special in a pattern, and that's what  
the String#match expects as an argument.  You can use Regexp.escape  
to escape special characters:

mike$ irb --prompt simple
 >> arg1 = "(1)a"
=> "(1)a"
 >> arg2 = "(1)a"
=> "(1)a"
 >> arg1.match(arg2)
=> nil
 >> arg1.match(Regexp.escape(arg2))
=> #<MatchData:0x34d6ac>

Hope this helps,

Mike

-- 

Mike Stok <mike / stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.