# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?<!\w\.\w.|etc.)(?<=\.|\?|!)\s(?=\w)"
test_str = (" At present, I believe the \"deeply-involved\" contributor would need to fork the 'content' repo to their personal Github accounts, revise, and later do pull requests. An alternative workflow was considered that might involve more sophisticated use of Github, but after piloting it out, this seemed like it would be hard to explain and enforce consistent use, esp. with github newbies. This was overkill; though this project may contain very modest amounts of code, it is not a coding project for a software product! I decided that this is best left to user's individual workflow. Some explanation of best practice, etc. this is a test. (e.g. for pull requests) might still be needed for the proposed workflow, but this is a lighter burden than the alternative\n\n"
"This is a ttest. \n"
"This is a test. this is another test\n\n\n"
"This is a ttest. \n"
"This is a test. this is another test")
subst = "\\r"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
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