# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?<=\w)\n(?=\w)"
test_str = ("Quality risk management. A systematic process for the assessment, control,\n"
"communication and review of risks to quality across the lifecycle. (ICH Q9)\n\n"
"Simulated agents. A material that closely approximates the physical and, where\n"
"practical, the chemical characteristics, e.g. viscosity, particle size, pH etc., of the product\n"
"under validation.\n\n"
"State of control. A condition in which the set of controls consistently provides assurance\n"
"of acceptable process performance and product quality.\n\n"
"Traditional approach. A product development approach where set points and operating\n"
"ranges for process parameters are defined to ensure reproducibility.\n\n"
"Worst Case. A condition or set of conditions encompassing upper and lower processing\n"
"limits and circumstances, within standard operating procedures, which pose the greatest\n"
"chance of product or process failure when compared to ideal conditions. Such conditions\n"
"do not necessarily induce product or process failure.\n\n\n"
"User requirements Specification (URS). The set of owner, user and engineering\n"
"requirements necessary and sufficient to create a feasible design meeting the intended\n"
"purpose of the system.")
subst = " "
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0)
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