Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Java lacks syntax

Last post 09-26-2009, 3:14 AM by CodesAway. 0 replies.
Sort Posts: Previous Next
  •  09-26-2009, 3:14 AM 56454

    Java lacks syntax

    Simply put, Java regular expression syntax is no where close to other languages.  Like many other Java programmers, this lack of functionality is painfully obvious when I try to use a regular expression written in Perl/PCRE, .NET, or Ruby and try to use it in Java.  Constructs such as named capture groups are just now appearing in Java 7, but are severely limited. Also, Java doesn't have support for matching numeric ranges, conditionals, perl's "branch reset" pattern, or many of the other useful syntax.

    Well, instead of growing tired of this, I thought I would do something about it. 

     

    I developed a Java library that adds much needed syntax support for the constructs mentioned above, and others, enabling usage of regular expressions written in other languages to be used in Java.  The library is called RegExPlus, codesaway.info/RegExPlus/, and there is an online tester supporting the same syntax, codesaway.info/JavaStar.  

    RegExPlus adds support for the familiar syntax found in Perl/PCRE and .NET, but lacking in Java.  Additionally, flags were added to Java's flags to allow entering a regular expression that uses Perl's octal syntax, or .NET's numbering for capture groups, along with .NET's explicit capture flag, to allow using regular expressions in Java that you already use in another language.

    Sorry about the shameless plug for my library, but I promise, it greatly enhances Java regular expression support, and as an added bonus, it runs on Java 1.5+, and uses Java's native regular expression.  RegExPlus is only responsible for refactoring the regex to an equivalent form, usable in Java.  All functions in the Pattern / Matcher classes are provided, along with many additional ones, so it's 100% backwards compatible. It utilizes Java's regex engine (providing the optimizations that it has), and you get to use the same syntax and regular expressions you already use in other languages.


    Check out http://codesaway.info/RegExPlus/, Java regex library supporting many features including named capture groups, conditionals, numeric ranges, Perl's branch reset pattern, ...
View as RSS news feed in XML