Need to remove the arabic text using regex

Hi folks, Can anyone please help me on this.

Need to find if the string contains any arabic text or numbers, if that exists means i need to remove the arabic words alone from it.

Sample
Input String - الإجراء المطلوب عزيزى المورد تمت الموافقة على اتفاقية شراء عامة جديد رقم (94411-A)
Output - (94411-A)

Input String - الإجراء المطلوبabcd123عزيزى المورد تمت الموافقة على اتفاقية شراABCء عامة جدي
Output - abcd123ABC

Hello @Raju23c,

Try this :point_down:

https://regex101.com/r/UMqSDJ/1

Hi @mz3bel …thanks for your input, i tried this and its not working for the sample input that i gave.

Hi,
check:
System.Text.RegularExpressions.Regex.IsMatch(your_String,".[a-zA-Z0-9-()]")

Arabic text is respresented as non-word character.
Or use nagation of Arabic characters like:

System.Text.RegularExpressions.Regex.IsMatch(your_String,"[\P{Arabic}\s\p{N}]")

Replace:

System.Text.RegularExpressions.Regex.Replace(your_String,"[\p{Arabic}\s]","")

Sources:
http://www.regular-expressions.info/unicode.html#category
https://www.fileformat.info/info/unicode/category/index.htm

1 Like

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Replace(yourString,"\p{IsArabic}","")

Regards,