Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created January 21, 2012 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rubiii/1653764 to your computer and use it in GitHub Desktop.
Save rubiii/1653764 to your computer and use it in GitHub Desktop.
reuse xml schema pattern via nokogiri
<xsd:pattern xmlns:xsd="http://www.w3.org/2001/XMLSchema" value="\d{3}-[A-Z]{2}"/>
require "nokogiri"
xml = File.read("pattern.xml")
node = Nokogiri.XML(xml).root
node["value"].match("123-AB")
# => nil
@emrox
Copy link

emrox commented Jan 21, 2012

/#{node["value"]}/.match("123-AB")
# => #<MatchData "123-AB">

@rubiii
Copy link
Author

rubiii commented Jan 21, 2012

yeah. it works. must be some other problem in this parser-wtf thingy. thx :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment