How do you unit test regular expressions?

后端 未结 10 733
长发绾君心
长发绾君心 2020-12-12 11:05

I\'m new to TDD, and I find RegExp quite a particular case. Is there any special way to unit test them, or may I just treat them as regular functions?

10条回答
  •  悲哀的现实
    2020-12-12 11:51

    I like to test the regexp against an opposite regex, I'll execute both against the possible test and make sure that the intersection is empty.

提交回复
热议问题