共有 0 个贴子
没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > pattern-builder |
pattern-builder
|
0 | 0 | 13 |
贡献者 | 讨论 | 代码提交 |
Although regular expressions are an efficient way of describing a language, sometimes they can get a bit complex and start to loose readability.
Python provides a way to document regular expression patterns within themselves. This can be achieved in Java setting the COMMENTS flag on matching process. Although this helps a lot, you still need the comments by hand to reflect the intention of each pattern.
pattern-builder takes a different approach allowing the programmer to specify the patterns explicitly in a functional manner. Here's an example of this:
// "[a-zA-Z]+"
Pattern onlyLettersPattern =
characterClass(
anyInRange("a", "z")
.orAnyInRange("A", "Z")
).oneOrMoreTimes()
.compile();With this approach, the programmer doesn't need to remember what each pattern did, and can rely on today's modern IDEs auto-completion features.
The interface is inspired in guava-libraries and google-collections.