# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"""
( # 1: start
( # 2: look for header...
( # 3: start
(ht|f)tps?\: # 4: http or some variant, or
)| # 3: end.
(www) # 5: www.
) # done with header.
(?: # start repeating group
([.\/:?=&-]+) # 6: allowed punctuations
( # 9: start. chose one:
(((\s?)([a-z0-9]+) # a space and lower case chars
)| #or
(\w+) # 11: all word chars, but no spaces
)
) # 9: end.
)+ # end repeating group
) # end capture group 1
(\/?\.?\s?[A-Z]?) # exclude this.
"""
test_str = (" us at https://www.roblox.com/support. If anyone asks for your password or personal information (such as your name, address or (https://www.roblox.com/support). If we choose to take action, Devs and Payors agree that our decision (which may include deducting Robux from the Dev and crediting of Robux to the Payor) is final and Devs and Payors shall abide by that decision. You agree to work with us in a timely manner to resolve all such issues, and failure to do so is considered a violation of these Terms.\n"
"B. Privacy Policy. At all times your information will be treated in accordance with Appleās Privacy Policy, which is incorporated by reference into this License and can be viewed at: http:// www.apple.com/privacy/.")
subst = "--------->$1<--------$13"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE | re.VERBOSE)
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.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html