I need to do a search for people who are violating our ‘don’t use social security numbers in your data’ rule and need to know if there are performance differences (and why) between the two lines below.
Thanks.
[0-9]{3}-[0-9]{2}-[0-9]{4}
vs
\d\d\d-\d\d-\d\d\d\d
Requested Details:
engine: removed to stop confusion in tagging
I think you would see very negligible differences in performance. Use the first one, as it is easier to read at a glance. Once the Regex is compiled (if you are compiling it before using it for reuse purposes), it would not matter anyway.
Don’t optimize until you need to optimize.