python how to ceck if string match regex code example
Example: check if valid regex string python
import re
string = '['
try:
re.compile(string)
is_valid = True
except re.error:
is_valid = False
import re
string = '['
try:
re.compile(string)
is_valid = True
except re.error:
is_valid = False