Project

General

Profile

Bug #12728 » rx-mini.rb

rklemme (Robert Klemme), 09/06/2016 01:54 PM

 
#!/usr/bin/ruby


def t(rx, s)
m = s.match rx

if m
printf "MATCH\ns = '%s'\nrx = %p\nmatch = %p\n\n", s, rx, m
else
printf "NO MATCH\ns = '%s'\nrx = %p\n\n", s, rx, m
end
end

puts RUBY_DESCRIPTION

t %r{
(?<!\\)\( # outer bracket
.*

(?<!\\) ([+*]|\{\d+,\}) (?!@) # inner repetition, non possessive

.*
(?<!\\)\) # outer bracket
(?<!\\) (?:[+*]|\{\d+,\}) # unbounded repetition, non possessive

}x, "f(o+@)+"

t %r{
(?<!\\)\( # outer bracket
.*

(?<!\\) ([+*]|\{\d+,\}) (?!\+) # inner repetition, non possessive

.*
(?<!\\)\) # outer bracket
(?<!\\) (?:[+*]|\{\d+,\}) # unbounded repetition, non possessive

}x, "f(o++)+"

t %r{
(?<!\\)\( # outer bracket
.*

(?<!\\) ([+*]|\{\d+,\}) (?![+]) # inner repetition, non possessive

.*
(?<!\\)\) # outer bracket
(?<!\\) (?:[+*]|\{\d+,\}) # unbounded repetition, non possessive

}x, "f(o++)+"

t %r{
(?<!\\)\( # outer bracket
.*

(?<!\\) ([+*]|\{\d+,\}) (?!@) # inner repetition, non possessive

.*
(?<!\\)\) # outer bracket
(?<!\\) (?:[+*]|\{\d+,\}) # unbounded repetition, non possessive

}x, "f(o+)+"

t %r{
(?<!\\)\( # outer bracket
.*

(?<!\\) ([+*]|\{\d+,\}) (?!\+) # inner repetition, non possessive

.*
(?<!\\)\) # outer bracket
(?<!\\) (?:[+*]|\{\d+,\}) # unbounded repetition, non possessive

}x, "f(o+)+"


(1-1/2)