官术网_书友最值得收藏!

Applicability and examples

The interpreter pattern can be used whenever an expression should be interpreted and transformed to its internal representation. The pattern cannot be applied to complex grammars since the internal representation is based on a composite pattern.

Java implements the interpreter pattern in java.util.Parser and it is used to interpret regular expressions. First, when a regular expression is interpreted, a matcher object is returned. The matcher uses the internal structure that was created by the pattern class based on the regular expression:

Pattern p = Pattern. compile("a*b");
Matcher m = p.matcher ("aaaaab");
boolean b = m.matches();
主站蜘蛛池模板: 西宁市| 仙桃市| 宁德市| 曲沃县| 安福县| 元阳县| 彰武县| 菏泽市| 贵州省| 抚宁县| 鲁山县| 万年县| 宁津县| 龙南县| 柳江县| 和政县| 华坪县| 钟山县| 常山县| 定襄县| 凯里市| 双柏县| 綦江县| 和顺县| 大荔县| 铁岭市| 宣威市| 叙永县| 蕲春县| 清水河县| 浦江县| 米脂县| 宝丰县| 临安市| 靖宇县| 惠州市| 鹤岗市| 寿阳县| 邹城市| 乌鲁木齐县| 策勒县|