我正在做一個簡單的函數,應該從阿拉伯文字刪除tashkeel,替換技術適用於英文,但不適用於阿拉伯文,你會建議什麼?如何從lua中的字符串中刪除tashkeel?
Lua代碼: -
function replacePartOfString(arg,old,new)
local zzz = arg.gsub(arg, old, new)
return zzz
end
function wordLengthIgnoringTashkeel(arg)
local tashkeelArray = {"َ","ً","ُ","ٌ","ِ","ٍ","ْ","َ"}
local tempWord = arg
print("tempWord Before"..tempWord)
for x=1,#tashkeelArray do
replacePartOfString(tempWord,tashkeelArray[x],"")
end
print("tempWord After"..tempWord)
end
結果
tempWordاليوم前tempWord後اليوم
而預期結果
預期的結果
tempWordاليوم前tempWord後اليوم
你爲什麼把android和ios標籤? – jonathanrz
你忘記捕捉你的函數返回的結果:'tempWord = replacePartOfString(...)' –
@jonathanrz:因爲我使用corona sdk。 – DeyaEldeen