- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 98字
- 2021-06-25 20:52:37
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();
推薦閱讀
- 玩轉Scratch少兒趣味編程
- Java多線程編程實戰(zhàn)指南:設計模式篇(第2版)
- Spring 5.0 By Example
- Mastering RabbitMQ
- 移動UI設計(微課版)
- 高效微控制器C語言編程
- Learn to Create WordPress Themes by Building 5 Projects
- HoloLens Beginner's Guide
- 算法基礎:打開程序設計之門
- Practical DevOps
- Neo4j Essentials
- MariaDB High Performance
- Unity Game Development Scripting
- Oracle從入門到精通(第5版)
- 小型編譯器設計實踐