internal static bool MatchHebrewDigits(ref __DTString str, int digitLen, out int number) {
number = 0;
// Create a context object so that we can parse the Hebrew number text character by character.
HebrewNumberParsingContext context = new HebrewNumberParsingContext(0);
// Set this to ContinueParsing so that we will run the following while loop in the first time.
HebrewNumberParsingState state = HebrewNumberParsingState.ContinueParsing;
while (state == HebrewNumberParsingState.ContinueParsing && str.GetNext()) {
state = HebrewNumber.ParseByChar(str.GetChar(), ref context);
}
if (state == HebrewNumberParsingState.FoundEndOfHebrewNumber) {
// If we have reached a terminal state, update the result and returns.
number = context.result;
return (true);
}
// If we run out of the character before reaching FoundEndOfHebrewNumber, or
// the state is InvalidHebrewNumber or ContinueParsing, we fail to match a Hebrew number.
// Return an error.
return false;
}