Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'pp'
- def doit(str)
- grant_regex = '
- ([^@]+) (?# user)
- @
- ([^\/]+) (?# host)
- (
- \/([^,]+) (?# database)
- (
- ,(\S+) (?# tables)
- )? (?# tables are optional)
- )? (?# database and tables are optional)
- '
- matches = Regexp.new(/^#{grant_regex}$/x).match(str).captures.compact
- matches.delete_at 2
- matches.delete_at 3
- pp matches
- end
- doit "pitc_puzzletime@10.2.%.%"
- doit "pitc_puzzletime@10.2.%.%/pitc_puzzletime_prod"
- doit "pitc_puzzletime@db-host.puzzl.ch/pitc_puzzletime_prod,diese_tabelle,andere_tabelle"
Add Comment
Please, Sign In to add comment