- 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();
推薦閱讀
- Qt 5 and OpenCV 4 Computer Vision Projects
- Visual C++串口通信開發(fā)入門與編程實踐
- C#程序設(shè)計實訓(xùn)指導(dǎo)書
- Maven Build Customization
- JavaScript Unlocked
- 從程序員到架構(gòu)師:大數(shù)據(jù)量、緩存、高并發(fā)、微服務(wù)、多團隊協(xié)同等核心場景實戰(zhàn)
- CouchDB and PHP Web Development Beginner’s Guide
- Flux Architecture
- Learning OpenCV 3 Computer Vision with Python(Second Edition)
- Java系統(tǒng)化項目開發(fā)教程
- Illustrator CC平面設(shè)計實戰(zhàn)從入門到精通(視頻自學(xué)全彩版)
- SQL Server 2016 從入門到實戰(zhàn)(視頻教學(xué)版)
- 愛上C語言:C KISS
- Practical Predictive Analytics
- 物聯(lián)網(wǎng)系統(tǒng)架構(gòu)設(shè)計與邊緣計算(原書第2版)