AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Regex java4/2/2023 ![]() This should not be a surprise, since the source code of the two methods is the same, a simple copy/paste in the JDK with the exception of the argument type. I tried the functionality using Java 9 build 160 and the outcome is the same for these two method versions. The text replaces “buffer” to “builder” and the like, and the text documenting the named reference feature is deleted. The documentation seems like it was copy/pasted and then edited. The StringBuilder argumented version misses this. The older StringBuffer-argumented method explicitly documents that the replacement string may contain named references that will be replaced by the corresponding group. It is interesting, though, how the currently online version of the API JDK documents the behaviour of appendReplacement for StringBuilder arguments. Considering that StringBuilder was introduced in Java 1.5, something like 13 years ago, nobody should say that this is an inconsiderate act. In the cases of appendReplacement and appendTail , the only difference is that the argument can also be a StringBuilder and not only a StringBuffer. The first four exist in earlier versions and there is only change in the types of the arguments (after all, that is what overloading means). Four of those are overloaded versions of already existing methods. The only class that has changed APIs is Matcher. It seems that regular expressions are so essential to Java that it got included in the base module. This makes the development a bit simpler: There is no need to explicitly ‘require’ a module if we want to use regular expressions in our code. The regular expression package is exported by this module. The module java.base is the default module on which all other modules depend on by default, and thus the classes of the exported packages are always available in Java applications. Java 17 is the latest long-term supported version (LTS). One could rightfully expect that there is a new module for regular expression handling packages and classes. Java was developed by James Gosling at Sun Microsystems ( later acquired by Oracle) the initial release of Java was in 1995. ![]() The JDK in Java 9 is split up into modules. In this article, I will focus on the few regular expression features that are specific to Java 9 and were not available in earlier version of the JDK. For those who know how to use RegEx, the book may still be interesting to reiterate the knowledge and to deepen into more complex features like zero length assertions, back references, and the like. The book is a good tutorial and introduction to anyone who wants to learn what regular expressions are and start from scratch. I recently received my complimentary copy of the book “Java 9 Regular Expressions” from Anubhava Srivastava published by Packt. ![]()
0 Comments
Read More
Leave a Reply. |