Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 09254fa112
Fetching contributors…

Cannot retrieve contributors at this time

102 lines (71 sloc) 3.13 KB
~Oniguruma for Ruby~
~~Ruby bindings for oniguruma~~
#Main# | index
= About =
This library provides bindings to [Oniguruma],
a regular expression library which is standard with Ruby 1.9. It allows users
of Ruby 1.8 to access the extended functionality without the need to recompile
or to upgrade Ruby.
This site provides an overview of the library, the api documentation is
= Requirements =
* [Oniguruma] regular expression library (/>= 4.x.x/)
= Installation =
If you have [rubygems] installation is straightforward by typing
(as root if needed):
--------hl shell-unix-generic,,false------
gem install -r oniguruma
If you prefer to get the sources, the last stable version may be
downloaded [here].
= Status =
The library interface is mature. Existing bugs are being fixed as they are
= Details =
Oniguruma provides the same functionality (and almost the same interface) than
standard regexp in Ruby. The main missing feature is the slash syntax to
declare regular expressions `/regexp/`. On the other hand, oniguruma provides
additional functionality:
* Extensive multibyte support.
-----------hl ruby,,false-----
reg = 'р(уби.*)', 'i', 'utf8' )
matches = reg.match("Text: Ехал Грека Через Реку")
puts matches[0] #=> "Ехал"
* Named groups.
-----------hl ruby,,false-----
reg = '(?<before>.*)(a)(?<after>.*)' )
match = reg.match( 'terraforming' )
puts match[0] #=> 'terraforming'
puts match[:before] #=> 'terr'
puts match[:after] #=> 'forming'
* Named backreferences.
-----------hl ruby,,false-----
re ='(?<pre>\w+?)\d+(?<after>\w+)')
puts re.sub('abc123def', ' \<after>123\<pre> ') #=> " def123abc "
* Positive and negative Lookbehind.
-----------hl ruby,,false-----
re ='(?>!g)ong')
m1 = re.match("song")
puts m1[0] #=> ong
m2 = re.match("gong") #=> nil
* Support for different regexp syntaxes (Python, Perl, etc.).
-----------hl ruby,,false-----
re = 'section{ (?P<name> [^}]* ) }', :syntax => SYNTAX_PYTHON )
re.sub('section{First}', 'subsection{\1}') #=> "subsection{First}"
# Links #
= Rubyforge project page =
* [Textpow].
= Documentation =
* [Api Documentation].
= Requirements =
* [Oniguruma].
= Projects using Textpow =
* [Textpow].
* [Ultraviolet Syntax Highlighting Engine].
* [Macaronic markup engine].
Jump to Line
Something went wrong with that request. Please try again.