Regex Generator
is a tool to generate simple regular expressions. The goal is that people with less experience can create regex smoothly.
Regex Generator tries to help you create a first version of a regular expression to recognize certain texts. It is designed to create regular expressions by putting together well-known snippets. This can be used as a starting point for regular expressions.
Hopefully nobody will need to use substring()
anymore.
Usage
Online
Just go to Regex Generator and try it online.
The page supports several search parameters to change the initial state of the options:
sampleText
changes the initial sample text of the regex generatorflags
changes the flags used to generate the language snippets. Any combination of the following characters are allowed:i
case insensitives
dot matches line breaksm
multiline
onlyPatterns
this controls the "Generate only patterns" check boxmatchWholeLine
this controls the "Match whole line" check boxselection
controls the matches that have been selected by the user
Docker
You can also start it via docker. Just use the following command and find Regex Generator on port 80 of your local machine:
docker run -d -p 80:80 noxone/regexgenerator
Of course the docker version supports the same search parameters as the actual website.
Development
Build
-
Clone the project
-
In the project's root directory execute
gradlew clean build
Or use docker to build the project:
docker build . -t noxone/regexgenerator
-
Find the output in directory
./build/distributions/
Live Development
For a nice development experience use
gradlew run --continuous
Using this command the page will reload automatically for every source file change.
Reports
Unit Tests
Well, we don't have enough unit tests. But there are a few. See the results.
Detekt
Detekt is a code style checker for Kotlin. It is integrated in the build process to keep the code clean.
You can find the Detekt report for this project here.
Project goal
As written in the introduction the aim of the project is to enable everybody to use regular expressions. The use of substring()
is nearly always unnecessary and if code is written in a reasonable manner you won't need that method.
There are a lot of very nice tools to build, understand and even debug your regex. Regex Generator
tries to add a little bit to these tools to give you at least a starting point how the regex you need might look like.
Hopefully this regex generator continues to grow to eventually support a really wide range of functions and regular expressions.
Languages
The regex generator
is currently able to generate code snippets in the following languages:
- C (using
regex.h
) - C#
- grep (command line tool)
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Swift
- Visual Basic .NET
If you miss a language, just open a new issue or if you like, program the corresponding generator and open a pull request.
Patterns
At the moment there are 28 patterns of different complexity integrated in regex generator
. It is able to recognize simple repetitions and combinations of multiple patterns.
In the final stage this Regex Generator shall support a wide range of use cases. Feel free to suggest new patterns via the issues.
More ideas
More ideas for new features or how to improve the application are very welcome. Please add them to the Github issues.