progs/re3ext.scala
author Christian Urban <urbanc@in.tum.de>
Mon, 24 Sep 2018 11:05:39 +0100
changeset 558 447ed6c7cdad
parent 422 5deefcc8cffa
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
     1
abstract class Rexp 
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
     2
case object ZERO extends Rexp
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
     3
case object ONE extends Rexp
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
case class CHAR(c: Char) extends Rexp
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
     5
case class ALT(r1: Rexp, r2: Rexp) extends Rexp
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
     6
case class SEQ(r1: Rexp, r2: Rexp) extends Rexp 
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
     7
case class STAR(r: Rexp) extends Rexp 
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
     8
case class NTIMES(r: Rexp, n: Int) extends Rexp 
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
     9
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    10
def simp(r: Rexp): Rexp = r match {
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    11
  case ALT(r1, r2) => {
341
ac1187b2e5c9 updated program
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 261
diff changeset
    12
    (simp(r1), simp(r2)) match {
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    13
      case (ZERO, r2s) => r2s
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    14
      case (r1s, ZERO) => r1s
341
ac1187b2e5c9 updated program
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 261
diff changeset
    15
      case (r1s, r2s) => if (r1s == r2s) r1s else ALT(r1s, r2s)
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    16
    }
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
  }
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    18
  case SEQ(r1, r2) => {
341
ac1187b2e5c9 updated program
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 261
diff changeset
    19
    (simp(r1), simp(r2)) match {
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    20
      case (ZERO, _) => ZERO
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    21
      case (_, ZERO) => ZERO
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    22
      case (ONE, r2s) => r2s
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    23
      case (r1s, ONE) => r1s
341
ac1187b2e5c9 updated program
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 261
diff changeset
    24
      case (r1s, r2s) => SEQ(r1s, r2s)
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    25
    }
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  }
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    27
  case NTIMES(r, n) => NTIMES(simp(r), n)    
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    28
  case r => r
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
def nullable (r: Rexp) : Boolean = r match {
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    32
  case ZERO => false
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    33
  case ONE => true
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  case CHAR(_) => false
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  case ALT(r1, r2) => nullable(r1) || nullable(r2)
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  case SEQ(r1, r2) => nullable(r1) && nullable(r2)
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  case STAR(_) => true
59
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
    38
  case NTIMES(r, i) => if (i == 0) true else nullable(r)
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
def der (c: Char, r: Rexp) : Rexp = r match {
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    42
  case ZERO => ZERO
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    43
  case ONE => ZERO
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    44
  case CHAR(d) => if (c == d) ONE else ZERO
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  case ALT(r1, r2) => ALT(der(c, r1), der(c, r2))
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  case SEQ(r1, r2) => 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
    if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
    else SEQ(der(c, r1), r2)
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  case STAR(r) => SEQ(der(c, r), STAR(r))
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
  case NTIMES(r, i) => 
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    51
    if (i == 0) ZERO else SEQ(der(c, r), NTIMES(r, i - 1))
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
def ders (s: List[Char], r: Rexp) : Rexp = s match {
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  case Nil => r
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    56
  case c::s => ders(s, simp(der(c, r)))
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
261
24531cfaa36a updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    59
def matches(r: Rexp, s: String) : Boolean = nullable(ders(s.toList, r))
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
//one or zero
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    63
def OPT(r: Rexp) = ALT(r, ONE)
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    65
def EVIL(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n))
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
def time_needed[T](i: Int, code: => T) = {
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
  val start = System.nanoTime()
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  for (j <- 1 to i) code
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  val end = System.nanoTime()
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  (end - start)/(i * 1.0e9)
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    74
/*
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    75
for (i <- 1 to 9001 by 1000) {
261
24531cfaa36a updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    76
  println(i + " " + "%.5f".format(time_needed(1, matches(EVIL(i), "a" * i))))
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
}
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    78
*/
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    80
// some convenience for typing in regular expressions
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    81
import scala.language.implicitConversions    
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    82
import scala.language.reflectiveCalls 
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    83
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    84
def charlist2rexp(s : List[Char]) : Rexp = s match {
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
    85
  case Nil => ONE
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    86
  case c::Nil => CHAR(c)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    87
  case c::s => SEQ(CHAR(c), charlist2rexp(s))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    88
}
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    89
implicit def string2rexp(s : String) : Rexp = charlist2rexp(s.toList)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    90
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    91
implicit def RexpOps (r: Rexp) = new {
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    92
  def | (s: Rexp) = ALT(r, s)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    93
  def % = STAR(r)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    94
  def ~ (s: Rexp) = SEQ(r, s)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    95
}
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    96
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    97
implicit def stringOps (s: String) = new {
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    98
  def | (r: Rexp) = ALT(s, r)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
    99
  def | (r: String) = ALT(s, r)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   100
  def % = STAR(s)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   101
  def ~ (r: Rexp) = SEQ(s, r)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   102
  def ~ (r: String) = SEQ(s, r)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   103
}
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   104
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   105
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   106
def PLUS(r: Rexp) = SEQ(r, STAR(r))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   107
def RANGE(s: List[Char]) : Rexp = s match {
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   108
  case Nil => ZERO
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   109
  case c::s => ALT(CHAR(c), RANGE(s))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   110
} 
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   111
def NMTIMES(r: Rexp, n: Int, m: Int) : Rexp =
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   112
  if (n >= m) NTIMES(r, n) else ALT(NTIMES(r, m), NMTIMES(r, n, m - 1))
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   113
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   114
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   115
println("Coursework:")
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   116
val REG1 = PLUS(PLUS("a" ~ "a" ~ "a"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   117
val REG2 = PLUS(PLUS("aaaaaaaaaaaaaaaaaaa" ~ OPT("a")))  // 19 as ~ a?
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   118
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   119
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   120
//40 * aaa matches
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   121
//43 * aaa + aa does not
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   122
//45 * aaa + a
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   123
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   124
println("EVIL1:")
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   125
println(matches(REG1, "aaa" * 40))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   126
println(matches(REG1, "aaa" * 43 + "aa"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   127
println(matches(REG1, "aaa" * 45 + "a"))
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   128
println("EVIL2:")
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   129
println(matches(REG2, "aaa" * 40))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   130
println(matches(REG2, "aaa" * 43 + "aa"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   131
println(matches(REG2, "aaa" * 45 + "a"))
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   132
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   133
println("EMAIL:")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   134
val LOWERCASE = "abcdefghijklmnopqrstuvwxyz"
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   135
val DIGITS = "0123456789"
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   136
val EMAIL = PLUS(RANGE((LOWERCASE + DIGITS + "_" + "." + "-").toList)) ~ "@" ~ 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   137
            PLUS(RANGE((LOWERCASE + DIGITS + "." + "-").toList)) ~ "." ~
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   138
            NMTIMES(RANGE((LOWERCASE + ".").toList), 2, 6)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   139
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 341
diff changeset
   140
val my_email = "christian.urban@kcl.ac.uk"
422
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   141
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   142
println(matches(EMAIL, my_email))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   143
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   144
println(matches(NTIMES("a", 2), "a"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   145
println(matches(NTIMES("a", 2), "aa"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   146
println(matches(NTIMES("a", 2), "aaa"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   147
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   148
println(matches(NMTIMES("a", 2, 3), "a"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   149
println(matches(NMTIMES("a", 2, 3), "aa"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   150
println(matches(NMTIMES("a", 2, 3), "aaa"))
5deefcc8cffa updated programs
Christian Urban <urbanc@in.tum.de>
parents: 363
diff changeset
   151
println(matches(NMTIMES("a", 2, 3), "aaaa"))