Can I test if a regex is valid in C# without throwing exception

后端 未结 8 1856
挽巷
挽巷 2020-12-03 13:19

I allow users to enter a regular expression to match IP addresses, for doing an IP filtration in a related system. I would like to validate if the entered regular expression

8条回答
  •  攒了一身酷
    2020-12-03 13:39

    As long as you catch very specific exceptions, just do the try/catch.

    Exceptions are not evil if used correctly.

提交回复
热议问题