Greetings All;
I am starting to use regex. What I want to do is extract 2 or 3 Arabic words after a specific pattern.
eg:
If i have arabic string
inputtext = "تكريم الدكتور احمد زويل والدكتورة سميرة موسي عن ابحاثهم العلمية "
I need to extract the names after
الدكتور
and
والدكتورة
therefore, the output should be:
احمد زويل
سميرة موسى
what i have done so far:
inputtext = "تكريم الدكتور احمد زويل والدكتورة سميرة موسي عن ابحاثهم العلمية "
Pattern pattern = Pattern.compile("(?<=الدكتور).*");
Matcher matcher = pattern.matcher(inputtext);
boolean found = false;
while (matcher.find()) {
String match = matcher.group();
System.out.println("the match is: "+match);
found = true;
}
if (!found)
{
System.out.println("I didn't found the text");
}
but it returns:
احمد زويل والدكتورة سميرة موسي عن ابحاثهم العلمية
I don’t know how to add another template and how to stop after two words?
Could you help me with any ideas?
source
share