Skip to content

Instantly share code, notes, and snippets.

@Xonshiz
Created November 4, 2017 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xonshiz/c0eebb2f8dc0b45753090c6515ed2a3a to your computer and use it in GitHub Desktop.
Save Xonshiz/c0eebb2f8dc0b45753090c6515ed2a3a to your computer and use it in GitHub Desktop.
# Command Line : python argy.py --myRegex "(^[A-Z]\d[A-Z]\d)"
# Check the Image : https://ibb.co/g3JPNb
import argparse
import re
parser = argparse.ArgumentParser(description='https://plus.google.com/u/0/101601879152225382803/posts/627K5E1DmMj?cfem=1')
parser.add_argument('--version', action='store_true', help='Shows version and exits.')
required_args = parser.add_argument_group('Required Arguments :')
required_args.add_argument('-mr', '--myRegex', nargs=1, help='Passes the Regex Pattern.')
args = parser.parse_args()
user_pattern = args.myRegex[0]
if not user_pattern:
print("You did not tell me the Regex Pattern To Look For")
else:
print("Your Pattern : {0}".format(user_pattern))
my_string = "A1B2"
# (^[A-Z]\d[A-Z]\d)
m = re.compile("{0}".format(user_pattern))
print(m.search(my_string).group(0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment