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