Project

General

Profile

Bug #12728 » rx-mini.rb

rklemme (Robert Klemme), 10/01/2016 08:59 AM

 
#!/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+)+"


(2-2/2)