The Onigmo regular expression engine compiled to WASM and wrapped in a Ruby embrace.
I know what you're thinking. Onigmo is built into Ruby - why is this project necessary?? Simple! I created it to serve as an example of how to interact with a WASM module in Ruby. Onigmo is a non-trivial project and one that has real-world use-cases, which makes it a better case study than many of the examples that can be found online.
So, please don't use this project as your regular expression engine. But please do use it to learn how to call WASM functions from Ruby, read WASM memory, etc etc.
Compile a regex:
re = Onigmo::OnigRegexp.compile("[abc]")
Search for text:
match_data = re.search("foo a zoo")
match_data.captures # => [[4, 5]]
match_data.match(0) # => "a"
match_data.get_begin(0) # => 4
match_data.get_end(0) # => 5
The WASM module at vendor/onigmo.wasm was built from onigmo-wasm.
bundle exec rake
should do the trick.
Licensed under the MIT license. See LICENSE for details.
- ongimo-ruby: Cameron C. Dutro: http://github.com/camertron
- Onigmo: K. Takata: https://github.com/k-takata