Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enh] command line simplification

  • Loading branch information...
commit 695675d3b9b26315e72b17cd4f1fff05ce2235cd 1 parent 27b44c6
@asciimoo authored
Showing with 9 additions and 0 deletions.
  1. +1 −0  README.markdown
  2. +8 −0 exrex.py
View
1  README.markdown
@@ -90,6 +90,7 @@ optional arguments:
-c, --count Count matching strings
-m N, --max-number N Max number of strings - default is -1
-r, --random Returns a random string that matches to the regex
+ -s, --simplify Simplifies a regular expression
-d DELIMITER, --delimiter DELIMITER
Delimiter - default is \n
-v, --verbose Verbose mode
View
8 exrex.py
@@ -434,6 +434,11 @@ def argparser():
,default = False
,action = 'store_true'
)
+ argp.add_argument('-s', '--simplify'
+ ,help = 'Simplifies a regular expression'
+ ,default = False
+ ,action = 'store_true'
+ )
argp.add_argument('-d', '--delimiter'
,help = 'Delimiter - default is \\n'
,default = '\n'
@@ -461,6 +466,9 @@ def __main__():
if args['random']:
args['output'].write('%s%s' % (getone(args['regex'], limit=args['limit']), args['delimiter']))
exit(0)
+ if args['simplify']:
+ args['output'].write('%s%s' % (simplify(args['regex']), args['delimiter']))
+ exit(0)
try:
g = generate(args['regex'], args['limit'])
except Exception as e:
Please sign in to comment.
Something went wrong with that request. Please try again.