mercredi 25 mars 2015

how can i finding the index of non-ASCII character in python string?

Python has string.find() and string.rfind() to get the index of a substring in string.


And re.search(regex,string) to get the 'first index' of a substring in string. but, this function is return to match object :(


So i wonder, merge the two function. by a regex to check for the string and return the first index. (index is not match object type :b)


example :



string = "abcdeÿÿaaaabbbÿÿcccdddÿÿeeeÿÿ"
print custom(string)


result :



>>> 5


non-ASCII range is [^\x20-\x7E], how does implementation this function??


Aucun commentaire:

Enregistrer un commentaire