# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(^\t*)(\/\*\*\n\s*\*\s.*)((?:\n\s*\*(?!\s@since).*)*)\/"
test_str = (" /**\n"
" * PLL_Xliff_Import constructor.\n"
" */\n\n"
" /**\n"
" * Get errors from validating the xliff scheme and display them\n"
" *\n"
" * @return string\n"
" */\n\n"
" /**\n"
" * Parses an XML response body.\n"
" *\n"
" * @since 3.0.0\n"
" *\n"
" * @param DOMDocument $document A HTML document parsed by PHP DOMDocument.\n"
" *\n"
" * @return void\n"
" */")
subst = "$1$2\\n$1 * \\n$1 * @since 3.1$3/"
# 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