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

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();
主站蜘蛛池模板: 从江县| 尚志市| 明星| 伊金霍洛旗| 吉水县| 自治县| 阿克陶县| 岚皋县| 左权县| 平利县| 犍为县| 河东区| 青河县| 陇西县| 新田县| 屏边| 广宁县| 高邮市| 武定县| 兴海县| 镇平县| 高陵县| 庆云县| 木里| 松江区| 南木林县| 泰宁县| 遵义县| 子洲县| 兴海县| 新和县| 江都市| 景东| 达尔| 利津县| 阳谷县| 临沭县| 沁阳市| 榆中县| 桓仁| 会宁县|