Project

General

Profile

Bug #12728 ยป rx-mini.rb

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

 
1
#!/usr/bin/ruby
2

    
3

    
4
def t(rx, s)
5
  m = s.match rx
6

    
7
  if m
8
    printf "MATCH\ns = '%s'\nrx = %p\nmatch = %p\n\n", s, rx, m
9
  else
10
    printf "NO MATCH\ns = '%s'\nrx = %p\n\n", s, rx, m
11
  end
12
end
13

    
14
puts RUBY_DESCRIPTION
15

    
16
t %r{
17
    (?<!\\)\(                           # outer bracket
18
    .*
19

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

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

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

    
28
t %r{
29
    (?<!\\)\(                           # outer bracket
30
    .*
31

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

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

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

    
40
t %r{
41
    (?<!\\)\(                           # outer bracket
42
    .*
43

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

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

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

    
52
t %r{
53
    (?<!\\)\(                           # outer bracket
54
    .*
55

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

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

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

    
64
t %r{
65
    (?<!\\)\(                           # outer bracket
66
    .*
67

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

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

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

    
76