Dim
Dim

Reputation: 4807

Regular expression with RTL Language

I have this code:

patternString = "הבא  [a-fA-F0-9]{3,10}";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(strBody);
if (matcher.find())
{
    return matcher.group();
}

I have string strBody in Hebrew that is:

. משהו גדול קורה פה הבא  711063

I need only the number after the word "הבא" that may be 3-10 digits long.

What I get now as result is:

הבא  711063

Can you please help me?

Upvotes: 1

Views: 2038

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

Just capture the part you want to print through capturing group.

String strBody = ". משהו גדול קורה פה הבא  711063";
String patternString = "הבא  ([a-fA-F0-9]{3,10})";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(strBody);
if (matcher.find())
{
    System.out.println(matcher.group(1));
}

OR

You could try this regex also if you want to match only 3 to 10 digits following הבא string.

String patternString = "הבא  (\\d{3,10})";

Output:

711063

Upvotes: 1

Related Questions