Combining Devanagari characters

前端 未结 6 2013
礼貌的吻别
礼貌的吻别 2020-12-05 02:40

I have something like

a = \"बिक्रम मेरो नाम हो\"

I want to achieve something like

a[0] = बि
a[1] = क्र
a[3] = म
         


        
6条回答
  •  星月不相逢
    2020-12-05 03:25

    You can achieve this with a simple regex for any engine that supports \X

    Demo

    Unfortunately, Python's re does not support the \X grapheme match.

    Fortunately, the proposed replacement, regex, does support \X:

    >>> a = "बिक्रम मेरो नाम हो"
    >>> regex.findall(r'\X', a)
    ['बि', 'क्', 'र', 'म', ' ', 'मे', 'रो', ' ', 'ना', 'म', ' ', 'हो']
    

提交回复
热议问题