From: Mark Hahn Date: 2001-10-20T04:01:40+09:00 Subject: [ruby-talk:22789] Re: How to Convert String to Regex to Perform Exact Match MakeRegExp doesn't handle special chars? -----Original Message----- From: William Djaja Tjokroaminata [mailto:billtj@z.glue.umd.edu] Sent: Friday, October 19, 2001 11:46 AM To: ruby-talk ML; undisclosed-recipients: Subject: [ruby-talk:22784] Re: How to Convert String to Regex to Perform Exact Match Thanks for all the responses to my question. However, they do not solve my problem. As I wrote before, my intention is to do perfect matching as in another_str == str Using reg = Regexp.new (str) another_str =~ reg will work if str is simple such as 'abcde'. However, if it contains Regexp special characters, such as 'abc.de' then it won't work. What I want is a to_regexp function that performs this automatically for me: reg = /abc\.de/ instead of the simplistic reg = /abc.de/ Should I write the String#to_regexp by myself to handle all the Regexp special characters? Regards, Bill ============================================================================ Ned Konz wrote: : On Friday 19 October 2001 10:26 am, William Djaja Tjokroaminata wrote: :> I could not find a function that performs the "to_regexp" utility. : Regexp.new(str) : -- : Ned Konz : currently: Stanwood, WA : email: ned@bike-nomad.com : homepage: http://bike-nomad.com