https://github.com/danielfsousa/search-regex
Search for a regular expression in all files inside a folder
https://github.com/danielfsousa/search-regex
Last synced: 27 days ago
JSON representation
Search for a regular expression in all files inside a folder
- Host: GitHub
- URL: https://github.com/danielfsousa/search-regex
- Owner: danielfsousa
- License: mit
- Created: 2016-09-29T23:19:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-30T00:48:22.000Z (over 9 years ago)
- Last Synced: 2025-01-02T06:44:24.563Z (over 1 year ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SearchRegex
Search for a regular expression in all files inside a folder
## Requirements
* [Python 3.x](https://www.python.org/downloads/)
* [PDFMiner.six](https://github.com/goulu/pdfminer)
## Supported Files
* All non-binary files like TXT, HTML, PHP, PY, etc.
* PDF
## How to Install
```bash
$ pip install pdfminer.six
TODO
```
## How to Use
**1. Use in command-line:**
* [FOLDER]: The folder where the files are located (You can use -c for the current folder)
* [REGEX]: The regular expression to find
```bash
$ python search_regex.py [FOLDER] [REGEX]
```
E.g. Find the word 'programming':
```bash
$ python search_regex.py -c "programming"
```
E.g. Find emails:
```bash
$ python search_regex.py -c ".+@.+"
```
**2. Use as a library:**
result = SearchFiles(DIR, REGEX)
found_files = result.files
E.g Find emails:
```bash
>>> import os
>>> from modules.search_files import SearchFiles
>>>
>>> result = SearchFiles(os.getcwd(), ".+@.+")
>>> result.files
{'telefone_e_email.py': 1, 'example.py': 1, 'personal_emails.txt': 3}
>>> result.total_matches
5
>>> result.total_matches_files
3
>>> result.folder
'C:\\example'
>>> result.regex
'.+@.+'
```
## TODO
* Package this project
* Add support for DOC and DOCX
* Add support for EPUB
* Add support for MOBI
* Add support for compressed files like ZIP or RAR