Another way instead of escaping regex patterns?

Regexp.new(Regexp.quote('http://www.microsoft.com/'))

Regexp.quote simply escapes any characters that have special regexp meaning; it takes and returns a string. Note that . is also special. After quoting, you can append to the regexp as needed before passing to the constructor. A simple example:

Regexp.new(Regexp.quote('http://www.microsoft.com/') + '(.*)')

This adds a capturing group for the rest of the path.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)