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

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();
主站蜘蛛池模板: 铜陵市| 金寨县| 定结县| 宁化县| 成都市| 多伦县| 丁青县| 岳池县| 本溪| 北流市| 新化县| 景泰县| 北票市| 嘉义县| 曲阜市| 偏关县| 竹北市| 宾阳县| 万州区| 永安市| 延川县| 泰兴市| 丹巴县| 汉沽区| 龙口市| 德钦县| 尼玛县| 宽城| 吉安县| 渝北区| 海口市| 涿鹿县| 镇江市| 镇赉县| 舞钢市| 富源县| 德保县| 建瓯市| 枣庄市| 林甸县| 镇原县|