I have this regex ("^[-A-Z0-9-[O]]{1,8}$"
) comming from a client requirement (normally should not be changed).
But it doesn't work in python (it works in C).
from re import search
var = "MY01C0DE"
regex = "^[-A-Z0-9-[O]]{1,8}$"
print(search(regex, var))
this prints None.
But if I change the regex to "^[-A-NP-Z0-9]{1,8}$"
, this works.
from re import search
var = "MY01C0DE"
regex = "^[-A-NP-Z0-9]{1,8}$"
print(search(regex, var))
So basically the -[O]
part doesn't work in python if I understand correctly. But I have checked and this regex works in C.
Is there any way to make this way of excluding characters (-[O]
) work in python also?