RegexAI is a user-friendly library powered by generative AI, simplifying regular expression use. It interprets plain language regex queries, making data extraction and text manipulation easy. Whether you're a beginner or pro, RegexAI adapts to your needs, streamlining regex tasks for enhanced efficiency and accessibility.
pip install regexai
Try out RegexAI in your browser :
RegexAI is designed to be used in conjunction with regex. It makes regex conversational, allowing you to ask questions to your data in natural language.
For example, you can ask RegexAI to Find words that contain the letter 'q' but not followed by 'u,' and replace them with the word 'quarantined.' from the user given paragraph :
from regexai.pattern import apikey
# Sample paragraph and regex query
test_paragraph = """In a racecar, the radar detected an abnormal level of radioactive materials. Please contact support at support@example.com or visit our website at https://www.example.com. You can also reach us at +1 (123) 456-7890. For inquiries, please send an email to info@example.org. Remember, regex is a powerful tool that can validate 1234 different types of input data! Not all q
words are quirky, but regex can help you find them. Please enter your 16-digit credit card number: 4532015115898164."""
query = """ Find words that contain the letter 'q' but not followed by 'u,' and replace them with the word 'quarantined.' """
# Instantiate an object
od=apikey("your openai key")
print("Output : ", od.find_all(test_paragraph,query))
print("Generated Code for your Query : ")
print(od.get_pattern())
The above code will return the following:
Output : In a racecar, the radar detected an abnormal level of radioactive materials.
Please contact support at support@example.com or visit our website at https://www.example.com. You can also reach us at +1 (123) 456-7890. For inquiries, please send an email to info@example.org. Remember, regex is a powerful tool that can validate 1234 different types of input data! Not all quarantined words are quirky, but regex can help you find them.
Please enter your 16-digit credit card number: 4532015115898164.
Generated Code for your Query :
import re
result = re.sub(r'\bq(?!u)\w+\b', 'quarantined', da)
Of course, you can also ask RegexAI to perform more complex queries depending upon your need and requirements.
In order to protect your privacy and safety , we do not save any type of file or data on our side and the package totally runs on your local system.
Contributions are welcome! Please check out the to-dos below, and feel free to open a pull request.
To-dos:
- Connect with different file sources feteching from different databases.
- Ideas to bypass token limit set by openai.
- Multiagent capabilities to perform parallel operations on different chunk of text data.
- Any contributions which you think can boost regexai use in your daily life.
For more information, please visit our github page.
After installing the virtual environment, please remember to install pre-commit
to be compliant with our standards:
pre-commit install
RegexAI is licensed under the MIT License. See the LICENSE file for more details.
- This project is based on the regex library by independent contributors, but it's in no way affiliated with the regex project.
- This project is meant to be used as a tool for data extraction, feature processing from textual data, and it's not meant to be used for production purposes. Please use it responsibly.