Skip to content

Instantly share code, notes, and snippets.

@osleonard
Created December 3, 2013 10:11
Show Gist options
  • Save osleonard/7766937 to your computer and use it in GitHub Desktop.
Save osleonard/7766937 to your computer and use it in GitHub Desktop.
Help with regular expression,i want a regular expression to map to something like this AUO/11/794 or AUO/**/****
(?<School>\d{auo-AUO})\/(?<year>\d{11})\/(?<number>\d{10000})
@bjhaid
Copy link

bjhaid commented Dec 3, 2013

[65] pry(main)> a = "AUO/11/794"
=> "AUO/11/794"
[66] pry(main)> md = a.match(/(?\w{3})/(?\d{2})/(?\d+)/)
=> #<MatchData "AUO/11/794" school:"AUO" year:"11" number:"794">
[67] pry(main)> md[:school]
=> "AUO"
[68] pry(main)> md[:year]
=> "11"
[69] pry(main)> md[:number]
=> "794"

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