Xeger

Small library, producing random text matching arbitrary regular expressions. This fork is deployed to Maven central to make it available.

License

License

GroupId

GroupId

com.github.krraghavan
ArtifactId

ArtifactId

xeger
Last Version

Last Version

1.0.0-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

Xeger
Small library, producing random text matching arbitrary regular expressions. This fork is deployed to Maven central to make it available.
Project URL

Project URL

https://github.com/krraghavan/xeger
Source Code Management

Source Code Management

https://github.com/krraghavan/xeger/tree/master

Download xeger

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.krraghavan/xeger/ -->
<dependency>
    <groupId>com.github.krraghavan</groupId>
    <artifactId>xeger</artifactId>
    <version>1.0.0-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.krraghavan/xeger/
implementation 'com.github.krraghavan:xeger:1.0.0-RELEASE'
// https://jarcasting.com/artifacts/com.github.krraghavan/xeger/
implementation ("com.github.krraghavan:xeger:1.0.0-RELEASE")
'com.github.krraghavan:xeger:jar:1.0.0-RELEASE'
<dependency org="com.github.krraghavan" name="xeger" rev="1.0.0-RELEASE">
  <artifact name="xeger" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.krraghavan', module='xeger', version='1.0.0-RELEASE')
)
libraryDependencies += "com.github.krraghavan" % "xeger" % "1.0.0-RELEASE"
[com.github.krraghavan/xeger "1.0.0-RELEASE"]

Dependencies

compile (1)

Group / Artifact Type Version
dk.brics.automaton : automaton jar 1.11-8

test (3)

Group / Artifact Type Version
junit : junit jar 4.7
org.mockito : mockito-all jar 1.8.0
org.hamcrest : hamcrest-all jar 1.1

Project Modules

There are no modules declared in this project.

This is a maintenance fork of the Xeger library. It is a Java library for generating strings that match a specific regular expression. The original version of Xeger is available from this address, but development seems to have stopped:

http://code.google.com/p/xeger/

The objective of this fork is to simply maintain Xeger, fixing the reported bugs as they come. Pull requests are welcome, though :-).

For reference, I have copied several useful sections of the original website below.

Introduction

Think of it as the opposite of regular expression matchers. This library allows you to generate text that is guaranteed to match a regular expression passed in.

Let's take the regular expression: [ab]{4,6}c Using Xeger, you can now generate Strings matching this pattern like this:

String regex = "[ab]{4,6}c";
Xeger generator = new Xeger(regex);
String result = generator.generate();
assert result.matches(regex);

Limitations

Xeger does not support all valid Java regular expressions. The full set of what is defined here and is summarized below. Future versions might support a more complete set, in case of popular demand.

regexp  ::=     unionexp                
|                       
unionexp        ::=     interexp | unionexp     (union) 
|       interexp                
interexp        ::=     concatexp & interexp    (intersection)  [OPTIONAL]
|       concatexp               
concatexp       ::=     repeatexp concatexp     (concatenation) 
|       repeatexp               
repeatexp       ::=     repeatexp ?     (zero or one occurrence)        
|       repeatexp *     (zero or more occurrences)      
|       repeatexp +     (one or more occurrences)       
|       repeatexp {n}   (n occurrences) 
|       repeatexp {n,}  (n or more occurrences) 
|       repeatexp {n,m} (n to m occurrences, including both)    
|       complexp                
complexp        ::=     ~ complexp      (complement)    [OPTIONAL]
|       charclassexp            
charclassexp    ::=     [ charclasses ] (character class)       
|       [^ charclasses ]        (negated character class)       
|       simpleexp               
charclasses     ::=     charclass charclasses           
|       charclass               
charclass       ::=     charexp - charexp       (character range, including end-points) 
|       charexp         
simpleexp       ::=     charexp         
|       .       (any single character)  
|       #       (the empty language)    [OPTIONAL]
|       @       (any string)    [OPTIONAL]
|       " <Unicode string without double-quotes> "      (a string)      
|       ( )     (the empty string)      
|       ( unionexp )    (precedence override)   
|       < <identifier> >        (named automaton)       [OPTIONAL]
|       <n-m>   (numerical interval)    [OPTIONAL]
charexp ::=     <Unicode character>     (a single non-reserved character)       
|       \ <Unicode character>   (a single character)

Maven repository

A binary build of this library is available from my Maven Bintray repository:

<repositories>
  <repository>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
    <id>bintray-bluezio-maven</id>
    <name>bintray</name>
    <url>https://dl.bintray.com/bluezio/maven</url>
  </repository>
</repositories>

Versions

Version
1.0.0-RELEASE