Comments (7)
You can use basic shell features:
while read line; do exrex.py "$line"; done < patternfile.txt
Or
cat patternfile.txt | xargs -n 1 exrex.py
from exrex.
i'm using windows so i tested powershell and cmd still didn't test this in bash yet (may work)
in my case this will start new instances of exrex and the exe for each line
for /f "tokens=*" %G in ('type patternfile.txt') do (exrex "%~G")|exe params
i have to take a pic whenever exe exits,while starting new instances for each line
the result is a folder full of picture files and it is very tiring to check manually pic by pic if operation succeed knowing that exe don't return a success error code on exit.
i think is more flexible to let exrex do it without any hassle.
by the way the legacy regex linux and windows apps have this feature:
grep -f, --file=FILE load the PATTERN from this FILE
findstr /G:file Gets the strings to search for from the specified file
from exrex.
You won't reach your goal without a tiny programming effort.
from exrex.
i followed your advice and you were right some tiny effort did the job
#add this in argparser() function
argp.add_argument(
'-f', '--rexfile',
help='get regular expression pattern from file',
metavar='REGEX',
default=False,
type=argparse.FileType('r', encoding='utf-8')
)
#add this in __main__ function try block
if (args['regex'] == "" and args['rexfile'] != ""):
for line in args['rexfile'].readlines():
g = generate(line, args['limit'])
elif(args['regex'] != ""):
g = generate(args['regex'], args['limit'])
from exrex.
for /f "tokens=*" %G in ('type patternfile.txt') do (exrex "%~G")|exe params
There's only 1 method to start a single instance: creating a concatenated string from the params. Every single other (that I know of) starts a new instance.
Pretty sure there's a command for screenshots like on Linux, even if you need to install another app. I think it can be done with FFmpeg.
from exrex.
#add this in argparser() function argp.add_argument( '-f', '--rexfile', help='get regular expression pattern from file', metavar='REGEX', default=False, type=argparse.FileType('r', encoding='utf-8') ) #add this in __main__ function try block if (args['regex'] == "" and args['rexfile'] != ""): for line in args['rexfile'].readlines(): g = generate(line, args['limit']) elif(args['regex'] != ""): g = generate(args['regex'], args['limit'])
after testing and testing again i noticed that only the last line is generated from the patternfile.txt,don't understand why
please help
from exrex.
work successfully
if (args['regex'] == "" and args['rexfile'] != ""):
for line in args['rexfile'].readlines():
try:
g = generate(line.rstrip(), args['limit'])
except Exception as e:
args['rexfile'].close()
stderr.write('[!] Error: %s\n' % e)
exit(1)
args['output'].write(next(g))
args['max_number'] -= 1
for s in g:
if args['max_number'] == 0:
break
args['max_number'] -= 1
args['output'].write(args['delimiter'])
args['output'].write(s)
if args['delimiter'] == '\n':
args['output'].write('\n')
args['rexfile'].close()
elif(args['regex'] != ""):
try:
g = generate(args['regex'], args['limit'])
except Exception as e:
stderr.write('[!] Error: %s\n' % e)
exit(1)
args['output'].write(next(g))
args['max_number'] -= 1
for s in g:
if args['max_number'] == 0:
break
args['max_number'] -= 1
args['output'].write(args['delimiter'])
args['output'].write(s)
if args['delimiter'] == '\n':
args['output'].write('\n')
exrex -f paternfile.txt ""
from exrex.
Related Issues (20)
- backreference issue
- Randomize All
- Multiple random results
- test `limit=` in `count()`
- Matching/generating incorrect strings
- Question about some sequences HOT 1
- Count is very inaccurate HOT 3
- I get empty lines instead of output HOT 1
- Lookahead support
- add is_infinite property/method
- simplification error with `|` and a prefix
- [solved] incorrect behavior in {n,m} Quantifier HOT 2
- expanding class digit range HOT 2
- [Feature Request] exrex in Golang HOT 1
- [feature req] Support POSIX chararacter classes
- Import error using Python 3.11.0 HOT 4
- __init__() got an unexpected keyword argument 'encoding'
- [Entity] Indian Aadhaar Number
- Branch master is missing the 0.11.0 release commit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exrex.