Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # encoding: utf-8
- unless RUBY_VERSION =~ /^1.9/
- $KCODE = 'u'
- puts "$KCODE == " + $KCODE
- else
- puts "Encoding == " + "".encoding.name
- end
- s = "a *b* c *d*<"
- # Extracted from redcloth3
- re = /(^|[>\s\(]) # sta
- (?!\-\-)
- (\*\*|\*|\?\?|\-|__|_|%|\+|\^|~|) # oqs
- (\*) # qtag
- (\w|[^\s].*?[^\s]) # content
- (?!\-\-)
- \*
- (\*\*|\*|\?\?|\-|__|_|%|\+|\^|~|) # oqa
- (?=[[:punct:]]|\s|\)|$)/x
- s.scan(re) { |m| p m }
- # Attempt to simplify the regex
- re = /(\*) # qtag
- ([^\*]) # content
- \*
- (?=[[:punct:]]|\s)/x
- s.scan(re) { |m| p m }
Add Comment
Please, Sign In to add comment