Can real Perl regular expressions be implemented in Java through an existing library?

Is there an existing robust Java library that implements a fairly substantial subset of Perl regular expression syntax?

Background:

I want to implement a rename file where renaming is done using Perl regular expressions.

The trick is that the project containing the mentioned renamer as a component is currently 100% Java in Windows.

NOTES:

I put off the obvious workaround for “install Strawberry Perl”, write all renamer in Perl (or teach Perl a Java coding developer), pass a list of files to rename to a Perl renamer script via a system call with Java “, too cunning and too evident:)

Also, don’t offer a comparison of how Java and the best RegEx engine are already good enough to do most of what Perl RegEx does - I know its functionality well enough (and maybe google); thus, I already know that this statement can be true; this, however, has nothing to do with my interest in the actual Perl RegEx syntax implemented as a Java library.

+4
source share
3 answers

Have you tried JRegex ? It boasts Perl 5.6 compatibility and doesn't worry about directly linking PCRE.

+7
source

For maximum compatibility with Perl, you will need to use Perl. You can do this using Inline :: Java :: Callback , which is distributed as part of Inline :: Java .

See also: How can I call Perl from Java?

+5
source

The library you are looking for is the Apache ORO library, it is specially implemented to handle Perl5 regular expressions.

+3
source

All Articles