質問

I am currently attempting to implement a regular expression engine. (Yes, for fun. Go fig.)

I am working from this site for general algorithmic approach: http://swtch.com/~rsc/regexp/regexp1.html

My question for you all is: do you know of a collection of regular expressions and text strings that I can use as a comprehensive testbed for my engine? I've been searching and asking around for a couple days now, and can't find anything specific; maybe my google keyword-fu is lacking.

Thanks!

p.s. By way of example:

regexs:

  • "a"
  • "abc"
  • "^a$"
  • "[a-c]"
  • "^[^a]$"
  • "^[^a]?$"
  • "a+"
  • "."
  • ".*"
  • ".+"
  • "da?[bd]"

strings:

  • ""
  • "a"
  • "h"
  • "dd"
  • "abc"
  • "dad"
  • "dabcd"
  • "aaaaab"
役に立ちましたか?

解決

Long ago I wrote a simple filename pattern matching function (file patterns are a special subset of regyular expressions). In the code (in C) I provided a few dozen test cases. You could probably adapt them for use with a regular expression matcher.

Source is at:
http://david.tribble.com/src/fpattern.c
http://david.tribble.com/src/fpattern.h

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top