I want to create search module in Arabic text by regular expression and C#. Can any one help me? I don't have any idea. In my search module, when user inert "??" without Alphabet (? ? ? ), module return ??? ??? ??? and others. how to create this module? thanks.
Search in richtext
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Naimish MakwanaRank #324 · 7.7K reputationPosted Aug 14, 2024, 12:43 AM EDT
You can use Regular Expressions (Regex) in C# to match the Arabic text. Here’s a basic example of how you can do this:
using System; using System.Text.RegularExpressions; public class Program { public static void Main() { string input = "?? ?? ??"; // Replace with your input string pattern = @"\p{IsArabic}+"; // This pattern matches Arabic text // Create a Regex Regex regex = new Regex(pattern); // Find matches MatchCollection matches = regex.Matches(input); // Loop through matches foreach (Match match in matches) { Console.WriteLine("Match found at index {0}. Length: {1}", match.Index, match.Length); } } }In this example,
\p{IsArabic}+is a Unicode character escape that matches any character in the Arabic Unicode category. The+means “one or more” of the preceding element.Please note that this is a very basic example. Depending on your specific requirements, you might need to adjust the regular expression or the way you handle the matches. If
Thanks