Earlier quoted context omitted.
Probably to check if a regular expression is valid
Yes, checking to see if a regular expression is valid is useful but that wasn't what I was asking. Why specifically would you want to use a regular expression for this job?
Still probably the library you are using exposes a validation function...