How to check regex is valid or not?

Hello

I want to check weather the regex is valid or not using search api and valid api validator.

Can any body help me out that how can I achieve this.

Query type can be : match all , match and some time wildcard.

Tried following things
{ "regexp":{ "columnName": { "value": "\/([A-Z])\\w+\/g", "flags" : "INTERSECTION|COMPLEMENT|EMPTY", "max_determinized_states": 20000 } } }

Thanks.