# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?<=\S)(?<!\bAbstract)(?:\n|\\n)(?=\S)"
test_str = ("Balanced Quantum Classical Evolutionary Algorithm(BQCEA)\n\n"
"Muhammad Shahid, Hasan Mujtaba, Muhammad Asim, Omer Beg\n\n"
"Abstract\n"
"With advancement in Quantum computing, classical algorithms are adapted and integrated\n"
"with Quantum properties such as qubit representation and entanglement. Although these\n"
"properties perform better however pre-mature convergence is the main issue in Quantum\n"
"Evolutionary Algorithms(QEA) because QEA uses only the best individual to update quan-\n"
"tum population. In this paper, we introduced a new way to update the quantum population\n"
"of QEA to avoid premature convergence\n\n"
"'Balanced Quantum Classical Evolutionary Algorithm(BQCEA)\\n\\nMuhammad Shahid, Hasan Mujtaba, \n"
"Muhammad Asim, Omer Beg\\n\\nAbstract\\nWith advancement in Quantum computing, classical \n"
"algorithms are adapted and integrated\\nwith Quantum properties such as qubit representation \n"
"and entanglement', ' Although these\\nproperties perform better however pre-mature \n"
"convergence is the main issue in Quantum\\nEvolutionary Algorithms(QEA) because QEA uses only \n"
"the best individual to update quan-\\ntum population', ' In this paper, we introduced a new \n"
"way to update the quantum population\\nof QEA to avoid premature convergence',")
subst = " "
# 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