How do you unit test regular expressions?

后端 未结 10 718
长发绾君心
长发绾君心 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条回答
  •  -上瘾入骨i
    2020-12-12 11:32

    I always test them just as I do any other function. Make sure they match things you think they should match and that they don't match things they shouldn't.

提交回复
热议问题