Name Initials

Published on Tue Mar 01 2022

Matches 2 or 3 initials from a name. If there is a "," and suffix like Jr., it does not include that in the result.

Additional matching regexes for
Name Initials

Name Initials

Matches 2 or 3 initials from a name. If there is a "," and suffix like Jr., it does not include that in the result.

include case

How to include the matched cases in the result?

Guid (with or without dashes)

Matches a guid string that can optionally include dashes.

Match initials

Match initials of a person name

Triple Quoted String

More powerful than python style, this supports things like `"""" """"`, which matches totally. Also supports `"""a""""""b"""`, where there are two matches: `"""a"""`,`"""b"""`.

Machine Readable Passport - Extractor

First version of MRP Extractor Future versions include 1. Merge with validator (if possible) 2. Check nationalities

Match the start of a link.

https:// http:// https://\/\/ https:\/\/\/\/\/\ https://\/\/ The reason I include [\/\\]* is because some links like: https://\/\/\/\/\/www.google.com actually work.

Proxy matcher

Matches proxies in ip:port format. Takes into account that octets cant start with a 0, and that octets that are not the first octet can be a 0 if there are no more numbers behind it.

Capture comma separated numbers

Capture comma separated numbers, no matter if there are spaces before or after the commas.

Python-Dunder-Underscore

# Python Dunder Underscore Regular Expression # ## Match ## ```python # coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r'^(__version__)(\s?=\s?)+("(.*)")' test_str = "__version__ = \"0.1.1.1\"" matches = re.search(regex, test_str) if matches: print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group())) for groupNum in range(0, len(matches.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.group(groupNum))) # Note: for Python 2.7 compatibility, use ur'' to prefix the regex and u"" to prefix the test string and substitution. ``` ## Substitution ## ### Full String Replacement ### ```python # coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r'^(__version__)(\s?=\s?)+("(.*)")' test_str = "__version__ = \"0.1.1.1\"" subst = "[Replacement]" # You can manually specify the number of replacements by changing the 4th argument result = re.sub(regex, subst, test_str, 1) if result: print (result) # Note: for Python 2.7 compatibility, use ur'' to prefix the regex and u"" to prefix the test string and substitution. ``` ### Dunder Replacement ### ```python # coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r'(__version__)(\s?=\s?)+("(.*)")' test_str = "__version__ = \"0.1.1.1\"" subst = "[Dunder-Replacement] \\g<3>" # You can manually specify the number of replacements by changing the 4th argument result = re.sub(regex, subst, test_str, 1) if result: print (result) # Note: for Python 2.7 compatibility, use ur'' to prefix the regex and u"" to prefix the test string and substitution. ``` ### Version Replacement ### ```python # coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r'(__version__)(\s?=\s?)+("(.*)")' test_str = "__version__ = \"0.1.1.1\"" subst = " \\g<1> = [Dunder-Replacement]" # You can manually specify the number of replacements by changing the 4th argument result = re.sub(regex, subst, test_str, 1) if result: print (result) # Note: for Python 2.7 compatibility, use ur'' to prefix the regex and u"" to prefix the test string and substitution. ```