Created
May 29, 2011 20:24
-
-
Save shadoi/998108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "yajl" | |
parser = Yajl::Parser.new | |
encoder = Yajl::Encoder.new | |
regex = /(.*)asdf(\w+)\s+{3}/ | |
regex_json = encoder.encode(regex) | |
r = Regexp.new(parser.parse(regex_json)) | |
=> /(?-mix:.*asdf\w+\s+{3})/ | |
"fooasdfblah argasdfbuh wowasdfderp" =~ r | |
=> 0 | |
## END | |
require "yajl/json_gem" | |
regex = /(.*)asdf(\w+)\s+{3}/ | |
regex_json = regex.to_json | |
Regexp.new(JSON.parse(regex_json)) | |
JSON::ParserError: lexical error: inside a string, '\' occurs before a character which it may not. | |
"(?-mix:(.*)asdf(\w+)\s+{3})" | |
(right here) ------^ | |
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/yajl-ruby-0.8.2/lib/yajl/json_gem/parsing.rb:16:in `rescue in parse' | |
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/yajl-ruby-0.8.2/lib/yajl/json_gem/parsing.rb:13:in `parse' | |
from (irb):5 | |
from /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment