0
我想模擬python中的星號擴展匹配。例如:在Python腳本中應用星號擴展表達式匹配
3494ZXXXXXX
將匹配:
34941000000
但不匹配:
34940000000
我想支持星號提供的任何匹配運算。我沒有可用的星號,因此不能使用AMI。所以,我需要的是實現此功能的方法:
def asterisk_extension_match(extension, pattern):
'''Returns True if the extension matches the pattern,
according to the asterisk extension matching rules'''
# Compute matches
return matches
是否有實現這種模式匹配任何庫,或我有使用正則表達式或類似它來模擬?我需要重新發明輪子嗎?
看起來很有趣。不知道這是否涵蓋所有可能的星號匹配模式,但我會嘗試。我還計劃提供一個匹配表,並預編譯正則表達式,這種方法將使它成爲可能。 – dangonfast