You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

hu.webarticum.strex:strex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hu.webarticum.strex:strex

Strex - Generate sorted string list from a regular expression


Version published
Maintainers
1

Readme

Source

Strex

Generate a sorted string list from a regular expression.

Strex is a java library for generating an alphabetically sorted lazy list of all the strings that match a given fixed-length regular expression.

Add to projects

Gradle projects:


dependencies {
    implementation "hu.webarticum.strex:strex:${strexVersion}"
}

Maven projects:

<dependency>
  <groupId>hu.webarticum.strex</groupId>
  <artifactId>strex</artifactId>
  <version>${strexVersion}</version>
</dependency>

Example

Here is a little demonstration of the key features:

Strex identifiers = Strex.compile("PID:\\d{3}\\-[a-f]{5}\\-[xrbc]{3}");
System.out.println(identifiers.size());                       // 497664000 ( = 10^3 × 1 × 6^5 × 1 × 4^3 )
System.out.println(identifiers.get(0));                       // PID:000-aaaaa-bbb
System.out.println(identifiers.get(497663999));               // PID:999-fffff-xxx
System.out.println(identifiers.indexOf("PID:354-fedab-xbb")); // 176650096

Features

Currently, a limited subset of regular expression features is supported:

  • simple literals (e. g. a)
  • escaped literals (e. g. \t, \.)
  • normal character classes (e. g. [a-f\d])
  • negated character classes (e. g. [^\da-fA-F])
  • predefined character classes (\s, \S, \w, \W, \d, \D)
  • dot (.), generates a printable ASCII character
  • fixed quantifier (e. g. {3})
  • optional ^ and $ anchors
  • non-ascii characters (e. g. ű{3}[a-záé])

In the future, it's planned to extend this functionality to support dynamic-length patterns, but this requires a completely new, much more complex engine. This is a low-priority task.

What is this good for?

There are many regex-based random string generators. Strex's main goal is different. It provides the full list of matching strings alphabetically sorted (even if the trivial tree traversal would not give an alphabetical result). This list can be very large, so simply sorting is not an option.

HoloDB uses Strex for generating random strings by a regex. To achieve this, it selects random indices (in an invertible way) and provides the associated strings for these. Because we can execute an efficient search in this virtual list, such table columns can be indexed.

FAQs

Package last updated on 15 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc