mruby/mruby — pull request #850 by mattn (2013-02-18 06:06:34+00:00)
Title: Pluggable regexp

This solution closes following issues.

#444
#719
#841

# VM don't provide Regexp

mruby provides basicaly functions to string match or string replace. `//` generate empty Regexp class instance. So `/[a-z]/.match("foo")` occur error `not implemented`.

# Pluggable Regexp

This change allow to overwrite Regexp by mrbgem. For example, [HsRegexp](https://github.com/masamitsu-murase/mruby-hs-regexp.git) is one of implementation.

If you do `Regexp=HsRegexp` at initialization of mruby, you will be able to use some functions of Regexp.

```ruby
//.match("foo")
```

# Known Issue

However, this change does not provide overwrite of String methods. So you should overwrite them by using alias_method for your self.

```
class String
alias_method :old_gsub, :gsub
def gsub(*arg)
if arg.class.to_s == 'String'
return old_gsub(*a)
else
return "replaced-string-by-your-regexp-gem"
end
end
end