TypeError: Can't convert re.compile('[A-Z]+') (re.Pattern) to Union[str, tokenizers.Regex]
I'm having issues applying a Regex expression to a Split() operation found in the HuggingFace Library. The library requests the following input for Split().

pattern (str or Regex) – A pattern used to split the string. Usually a
string or a Regex

In my code I am applying the Split() operation like so:
tokenizer.pre_tokenizer = Split(pattern=&quot;[A-Z]+&quot;, behavior='isolated')

but it's not working because [A-Z]+ is being interpreted as  a string not a Regex expression. I've used the following to no avail:
pattern = re.compile(&quot;[A-Z]+&quot;)
tokenizer.pre_tokenizer = Split(pattern=pattern, behavior='isolated')

Getting the following error:

TypeError: Can't convert re.compile('[A-Z]+') (re.Pattern) to Union[str, tokenizers.Regex]


The following solution worked by importing Regex from the tokenizers library:
from tokenizers import Regex

tokenizer.pre_tokenizer = Split(pattern=Regex(&quot;[A-Z]+&quot;),
                                behavior='isolated')

