diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-07 02:59:33 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-07 02:59:33 +0000 |
commit | 66a425c65cef32e950200ec4000724c76217014e (patch) | |
tree | 263e3d4858f4a73885c778ce3f41c34285102a59 | |
parent | fed549a10437f54588e0b1e0e9bd883d59bd37a6 (diff) | |
download | ruby-66a425c65cef32e950200ec4000724c76217014e.tar.gz |
* lib/rexml/quickpath.rb (REXML::QuickPath::predicate): fix regexp.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/rexml/quickpath.rb | 5 |
2 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Wed Apr 7 11:49:34 2010 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/rexml/quickpath.rb (REXML::QuickPath::predicate): + fix regexp. + Wed Apr 7 09:44:48 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * configure.in (Makefile): quote init-commands. diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb index 95fc72b7c2..3ad8023470 100644 --- a/lib/rexml/quickpath.rb +++ b/lib/rexml/quickpath.rb @@ -141,6 +141,7 @@ module REXML return matches.uniq end + OPERAND_ = '((?=(?:(?!and|or).)*[^\s<>=])[^\s<>=]+)' # A predicate filters a node-set with respect to an axis to produce a # new node-set. For each node in the node-set to be filtered, the # PredicateExpr is evaluated with that node as the context node, with @@ -170,7 +171,9 @@ module REXML rest = path[ind+1..-1] # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c' - predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u, + # + predicate.gsub!( + /#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u, '\1 \2 \3 and \3 \4 \5' ) # Let's do some Ruby trickery to avoid some work: predicate.gsub!( /&/u, "&&" ) |