mardi 23 mars 2021

How to pass regex in presidio library

I want to recognize my custom pattern using Microsoft's Presidio library in python. while passing the regex I am getting this error. AttributeError: 'str' object has no attribute 'regex'

from presidio_analyzer import PatternRecognizer
regex = ("^[2-9]{1}[0-9]{3}\\" +
             "s[0-9]{4}\\s[0-9]{4}$")
#p = re.compile(regex)
aadhar_number_recognizer = PatternRecognizer(supported_entity="AADHAR_NUMBER",
                                      patterns=[regex])```

Aucun commentaire:

Enregistrer un commentaire