Search code examples
iosarraysswiftsplitarabic

Swift - Split text based on arabic combined characters


Dears,

I have arabic sentence like this stentence

أكل الولد التفاحة

how can i split the sentence based on UNCONNECTED characters to be like this :

أ- كل

ا- لو- لد

ا- لتفا- حة

I put - to explain what i mean. I just need to split the text into array based on that

How can i do that using swift code for ios ?

Update: I dont care for the spaces. "أكل" for example is one word and doesn't contain spaces.I want to split based on UNCONNECTED characters. So "أكل" consist from two objects : "أ" and "كل"

الولد : three objects "ا" and "لو" and "لد"


Solution

  • Use the below code:

    let a = "أكل الولد التفاحة".split(separator: " ")