|
| 1 | +<div align="center"> |
| 2 | + <img src="assets/regexplain.svg" alt="regexplain" width="200" height="200"> |
| 3 | + |
| 4 | + <h1>Regexplain</h1> |
| 5 | + |
| 6 | + <p> |
| 7 | + <a href="#features">features</a> • |
| 8 | + <a href="#Installation">Installation</a> • |
| 9 | + <a href="#Usage">Usage</a> |
| 10 | + </p> |
| 11 | + |
| 12 | + |
| 13 | + <p> |
| 14 | + <a href="https://github.com/Silent-Watcher/regexplain/blob/master/LICENSE"> |
| 15 | + <img src="https://img.shields.io/github/license/Silent-Watcher/regexplain?color=#2fb64e"license"> |
| 16 | + </a> |
| 17 | + </p> |
| 18 | + |
| 19 | + <p>⭐️ Please press the star! It greatly helps development! ⭐️</p> |
| 20 | + <p>A powerful command-line tool that demystifies regular expressions using AI-powered explanations. Regexplain helps developers understand complex regex patterns by providing clear, human-readable breakdowns.</p> |
| 21 | + |
| 22 | +</div> |
| 23 | + |
| 24 | + |
| 25 | +## ✨ Features |
| 26 | + |
| 27 | +- **AI-Powered Explanations**: Uses Groq's AI to generate comprehensive regex explanations |
| 28 | +- **Secure API Key Management**: Securely stores your Groq API key using system keychain |
| 29 | +- **Proxy Support**: Works behind corporate proxies with configurable proxy settings |
| 30 | +- **Developer-Friendly**: Built with TypeScript for reliability and type safety |
| 31 | +- **Zero Configuration**: Works out of the box with intuitive CLI interface |
| 32 | +- **Cross-Platform**: Compatible with Windows, macOS, and Linux |
| 33 | + |
| 34 | +## 🚀 Installation |
| 35 | + |
| 36 | +```bash |
| 37 | +npm install -g regexplain |
| 38 | +``` |
| 39 | + |
| 40 | +Or use without installation with npx: |
| 41 | + |
| 42 | +```bash |
| 43 | +npx regexplain <your-regex> |
| 44 | +``` |
| 45 | + |
| 46 | +## 📖 Usage |
| 47 | + |
| 48 | +```bash |
| 49 | +regexplain <regex-pattern> |
| 50 | +``` |
| 51 | + |
| 52 | +### Examples |
| 53 | + |
| 54 | +```bash |
| 55 | +# Explain a simple email regex |
| 56 | +regexplain '^[\\w.+\\-]+@[a-z\\d\\-.]+\\.[a-z]+$' |
| 57 | + |
| 58 | +# Explain a complex password validator |
| 59 | +regexplain '^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$' |
| 60 | +``` |
| 61 | + |
| 62 | +## Example Output |
| 63 | + |
| 64 | +``` |
| 65 | +📖 Explanation: |
| 66 | +
|
| 67 | +Breakdown: |
| 68 | +- ^ : Start of the string |
| 69 | +- [\w.+\-]+ : Matches one or more word characters, dots, plus signs, or hyphens |
| 70 | +- @ : Literal @ character |
| 71 | +- [a-z\d\-.]+ : Matches one or more lowercase letters, digits, hyphens, or dots |
| 72 | +- \. : Escaped dot character (literal .) |
| 73 | +- [a-z]+ : Matches one or more lowercase letters |
| 74 | +- $ : End of the string |
| 75 | +
|
| 76 | +Overall Purpose: This pattern validates email addresses with a relatively permissive approach, allowing various characters in the local part and standard domain format. |
| 77 | +
|
| 78 | +Example Matches: |
| 79 | +- user.name+tag@example.com |
| 80 | +- user-name@sub.domain.co |
| 81 | +
|
| 82 | +Non-Matches: |
| 83 | +- user@.com (missing domain name) |
| 84 | +- user@com (missing top-level domain) |
| 85 | +``` |
| 86 | + |
| 87 | +## CLI Design |
| 88 | + |
| 89 | +Regexplain features a minimalist CLI design focused on simplicity: |
| 90 | + |
| 91 | +``` |
| 92 | +regexplain <regex> Explain a regular expression |
| 93 | +``` |
| 94 | + |
| 95 | +The tool automatically: |
| 96 | +1. Handles API key management securely |
| 97 | +2. Provides option for proxy configuration |
| 98 | +3. Shows loading indicators during AI processing |
| 99 | +4. Formats output for optimal terminal readability |
| 100 | + |
| 101 | +## 🔧 Configuration |
| 102 | + |
| 103 | +### API Key Setup |
| 104 | +On first run, Regexplain will prompt for your Groq API key and store it securely in your system's keychain. Alternatively, you can set it as an environment variable: |
| 105 | + |
| 106 | +```bash |
| 107 | +export GROQ_API_KEY=your_api_key_here |
| 108 | +``` |
| 109 | + |
| 110 | +### Proxy Configuration |
| 111 | +Regexplain supports HTTPS proxies through: |
| 112 | +- Environment variables (`HTTPS_PROXY` or `https_proxy`) |
| 113 | +- Interactive prompt during execution |
| 114 | + |
| 115 | +## Who Will Find This Useful |
| 116 | + |
| 117 | +- **Frontend/Backend Developers**: Understand regex patterns in codebases |
| 118 | +- **Data Scientists**: Parse and understand data extraction patterns |
| 119 | +- **DevOps Engineers**: Debug log parsing rules and patterns |
| 120 | +- **Students**: Learn regular expressions through practical examples |
| 121 | +- **Technical Writers**: Document complex regex patterns accurately |
| 122 | +- **Code Reviewers**: Quickly understand regex logic during reviews |
| 123 | + |
| 124 | +## 🤝 Contributing |
| 125 | + |
| 126 | +Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md). |
| 127 | + |
| 128 | + |
| 129 | +## ⚠️ Limitations |
| 130 | + |
| 131 | +- Requires internet connection for AI explanations |
| 132 | +- Dependent on Groq API availability |
| 133 | +- Complex regex patterns may have longer processing times |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +**Note**: This tool is designed for educational and productivity purposes. Always test regex patterns thoroughly in your specific use case. |
| 138 | + |
| 139 | + |
| 140 | +## 📄 License |
| 141 | + |
| 142 | +MIT License - see [LICENSE](LICENSE) for details. |
| 143 | + |
| 144 | +## Support |
| 145 | + |
| 146 | +For support and questions, please open an issue on GitHub or contact [backendwithali@gmail.com](mailto:backendwithali@gmail.com) |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +<div align="center"> |
| 151 | + <p> |
| 152 | + <sub>Built with ❤️ by <a href="https://github.com/Silent-Watcher" target="_blank">Ali Nazari</a>, for developers.</sub> |
| 153 | + </p> |
| 154 | + <p> |
| 155 | + <a href="https://github.com/Silent-Watcher/regexplain">⭐ Star us on GitHub</a> • |
| 156 | + <a href="https://www.linkedin.com/in/alitte/">🐦 Follow on Linkedin</a> |
| 157 | + </p> |
| 158 | +</div> |
0 commit comments