Search code examples
pythonstringnlp

Is there python Function to remove word between special character and space


I'm trying to remove the *@hmo2406* word using the below function. Could you check and help me?

'*@hmo24* وين هل الغيبه  '

>>> import re
>>> re.sub('\n@.*?\n','',a, flags=re.DOTALL)

Solution

  • If you're removing non-Arabic characters from your string then try this:

    import re 
    
    text = '*@hmo24* وين هل الغيبه  '
    
    arabic_string = " ".join(re.findall('[\u0600-\u06ff]+', text))
    
    print(arabic_string)
    

    Output:

    وين هل الغيبه