After the installation of Oniguruma i have created the following regular
expression in ruby 1.8.7:
Oniguruma::ORegexp.new('(?:(?:\$(?\'name1\'[\w\s\']+)(?:(?\'name2\'(?:created|developed)[\w\s]+)(?\'name3\'(?:in|at)[\w\s]+)))|(?:\$(?\'name1\'[\w\s\']+)(?\'name2\'(:?created|developed)[\w\s]+))|(?:\$(?\'name1\'[\w\s\']+)(?\'name3\'(?:in|at)[\w\s]+)))(?:\.(?\'name4\'[\w\s]+))?').match(str)
My problem is that the result in ruby 1.8.7 is different from the result
in 1.9.1.
Anyone has an idea about what's going on?
I also tried to substitute ?\'name1\' with ?<name1>
After the installation of Oniguruma i have created the following regular
expression in ruby 1.8.7:
Oniguruma::ORegexp.new('(?:(?:\$(?\'name1\'[\w\s\']+)(?:(?\'name2\'(?:created|developed)[\w\s]+)(?\'name3\'(?:in|at)[\w\s]+)))|(?:\$(?\'name1\'[\w\s\']+)(?\'name2\'(:?created|developed)[\w\s]+))|(?:\$(?\'name1\'[\w\s\']+)(?\'name3\'(?:in|at)[\w\s]+)))(?:\.(?\'name4\'[\w\s]+))?').match(str)
My problem is that the result in ruby 1.8.7 is different from the result
in 1.9.1.
Anyone has an idea about what's going on?
I also tried to substitute ?\'name1\' with ?<name1>
What differences did you observe? Against which text did you match?
To simplify your tests I would create both regular expressions via the
string method. Then you can be sure to use the same string and not
fall culprit of some conversion or typing errors.
Kind regards
robert
···
2009/9/4 Miguel Teixeira <miguelfteixeira@gmail.com>:
I have the following regular expression created in ruby 1.9.1:
After the installation of Oniguruma i have created the following regular
expression in ruby 1.8.7:
Oniguruma::ORegexp.new('(?:(?:\$(?\'name1\'[\w\s\']+)(?:(?\'name2\'(?:created|developed)[\w\s]+)(?\'name3\'(?:in|at)[\w\s]+)))|(?:\$(?\'name1\'[\w\s\']+)(?\'name2\'(:?created|developed)[\w\s]+))|(?:\$(?\'name1\'[\w\s\']+)(?\'name3\'(?:in|at)[\w\s]+)))(?:\.(?\'name4\'[\w\s]+))?').match(str)
My problem is that the result in ruby 1.8.7 is different from the result
in 1.9.1.
Anyone has an idea about what's going on?
The problem is that in ruby 1.8.7 is impossible (?) to use string method with oniguruma (the default regular expression engine is different).
Apparently you are not getting my point - maybe I wasn't clear enough. I suggested to *create* the regular expression via a String, i.e. Regexp.new(s) and Oniguruma::ORegexp.new(s).
The differences that i observe is the match's for the cases where the (created|developed) and (in|at) groups should be matched.
What difference do you observe? You are not really providing much information to answer your question. You could do yourself a favor and simply post a script or IRB session showing the different behavior.
I get the same result when trying the match via Regexp.new.
Maybe the version of origuruma is different, i will try to create a
different regular expression (more simple) this times using ruby 1.8.7
regular expression engine.