Guest User

Untitled

a guest
May 23rd, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. require 'pp'
  2.  
  3. def doit(str)
  4. grant_regex = '
  5. ([^@]+) (?# user)
  6. @
  7. ([^\/]+) (?# host)
  8. (
  9. \/([^,]+) (?# database)
  10. (
  11. ,(\S+) (?# tables)
  12. )? (?# tables are optional)
  13. )? (?# database and tables are optional)
  14. '
  15.  
  16. matches = Regexp.new(/^#{grant_regex}$/x).match(str).captures.compact
  17. matches.delete_at 2
  18. matches.delete_at 3
  19. pp matches
  20. end
  21.  
  22. doit "pitc_puzzletime@10.2.%.%"
  23. doit "pitc_puzzletime@10.2.%.%/pitc_puzzletime_prod"
  24. doit "pitc_puzzletime@db-host.puzzl.ch/pitc_puzzletime_prod,diese_tabelle,andere_tabelle"
Add Comment
Please, Sign In to add comment