It will be useful for you if you need to get text which can be match with your existing regular expression in JAVA.

Recently a had same question. I use Xeger (http://code.google.com/p/xeger/).

First of all you need to download JAR from http://code.google.com/p/xeger/.

Next you need to run in command line next command:

mvn install:install-file -Dfile=~/Downloads/xeger-1.0-SNAPSHOT.jar -DgroupId=nl.flotsam -DartifactId=xeger -Dversion=1.0-SNAPSHOT -Dpackaging=jar

There is linux-path to JAR file (~/Downloads/xeger-1.0-SNAPSHOT.jar). groupId, artifactId, version …. for xeger-1.0-SNAPSHOT.jar file. If you use another you need make some changes in command.

Next you need to copy JAR file in to .m2/repository/nl/flotsam/xeger/1.0-SNAPSHOT dir

in order to use Xeger you need also install in maven repository the dk.brics.automaton package.

Here part of my pom.xml:

		<dependency>
			<groupId>nl.flotsam</groupId>
			<artifactId>xeger</artifactId>
			<version>1.0-SNAPSHOT</version>
		</dependency>
		<dependency>
            <groupId>dk.brics</groupId>
            <artifactId>automaton</artifactId>
            <version>1.11</version>
        </dependency>

If you have some questions you can create a comment for this post.

Have a nice codding!

Tags: , , , ,