Guest User

Untitled

a guest
May 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # encoding: utf-8
  2. unless RUBY_VERSION =~ /^1.9/
  3. $KCODE = 'u'
  4. puts "$KCODE == " + $KCODE
  5. else
  6. puts "Encoding == " + "".encoding.name
  7. end
  8.  
  9. s = "a *b* c *d*<"
  10.  
  11. # Extracted from redcloth3
  12. re = /(^|[>\s\(]) # sta
  13. (?!\-\-)
  14. (\*\*|\*|\?\?|\-|__|_|%|\+|\^|~|) # oqs
  15. (\*) # qtag
  16. (\w|[^\s].*?[^\s]) # content
  17. (?!\-\-)
  18. \*
  19. (\*\*|\*|\?\?|\-|__|_|%|\+|\^|~|) # oqa
  20. (?=[[:punct:]]|\s|\)|$)/x
  21.  
  22. s.scan(re) { |m| p m }
  23.  
  24. # Attempt to simplify the regex
  25. re = /(\*) # qtag
  26. ([^\*]) # content
  27. \*
  28. (?=[[:punct:]]|\s)/x
  29.  
  30. s.scan(re) { |m| p m }
Add Comment
Please, Sign In to add comment