RegexAI is a command-line tool built with Go that leverages the OpenAI GPT-3 model to generate regex patterns. It provides an intuitive interface to generate regex patterns right from your terminal.
- Go: Ensure that you have Go 1.18 or later installed on your system. You can check your Go installation by running
go version
in your terminal. If you don't have Go installed or have an older version, you can download the latest version from the official Go website. - OpenAI API Key: You can obtain an API key from OpenAI website.
To install RegexAI, follow the steps below:
-
Clone the RegexAI repository to your local machine:
git clone https://github.com/bugfloyd/regexai.git
-
Navigate to the cloned directory:
cd regexai
-
Copy the example .env file to
.env
:cp .env.example .env
-
Update the content of the
.env
file with your OpenAI API key. See the Configuration section for more details. -
Build the project:
go build
This will generate a binary named
regexai
. -
Add execution permissions to the binary:
chmod +x regexai
RegexAI is very simple to use. Here's the basic usage:
./regexai "email address"
This will generate a regex pattern for validating an email address.
If you'd like a short explanation about the generated regex, you can use the -e
or --explain
flag:
./regexai -e "email address"
Or:
./regexai --explain "email address"
This will generate a regex pattern along with a short explanation.
RegexAI uses the OpenAI API, and it requires an API key to function. The API key should be set in a .env
file in the root of the project. Here's a sample .env
file:
OPENAI_API_KEY=yourapikey
Replace yourapikey
with your actual OpenAI API key.
We welcome contributions from the community. If you'd like to contribute, please fork the repository and make your changes, then create a pull request against the main branch.
RegexAI is licensed under the GNU General Public License v2.0. See LICENSE
for more details.
This tool uses the OpenAI GPT-3 model, which is a powerful language model. However, it's not perfect, and it may not always generate the correct regex pattern. Always test the generated regex before using it in production.