import re
regex = re.compile((r'class MyNewLanguage extends PureComponent {\n\n'
r' //\n'
r' // Proptypes\n\n'
r' static propTypes = {\n'
r' regex: PropTypes.string.isRequired,\n'
r' flags: PropTypes.string.isRequired,\n'
r' delimiter: PropTypes.string.isRequired,\n'
r' testString: PropTypes.string.isRequired,\n'
r' isSubstituting: PropTypes.bool.isRequired,\n'
r' isGlobal: PropTypes.bool.isRequired,\n'
r' substString: PropTypes.string\n'
r' };\n\n'
r' //\n'
r' // Control\n\n'
r' // If you need to manipulate any data, you should preferably do it in a function defined \n'
r' // on the class body here. This could for example be sanitizing data (escaping quotes, etc).\n\n'
r' //\n'
r' // Render functions\n\n'
r' render() {\n'
r' return (\n'
r' <Highlight lang="myNewLanguage">\n'
r' {this._renderCode()}\n'
r' </Highlight>\n'
r' );\n'
r' }\n\n'
r' _renderCode() {\n'
r' const { regex, flags, delimiter, testString, isSubstituting, substString, isGlobal } = this.props;\n\n'
r' const codeString = new CodeString();\n'
r' \n'
r' // CodeString is a basic class that allows you to create a code snippet without having\n'
r' // to worry about indentation or newlines.\n\n'
r' // The only functions are `append`, `indent` and `toString`.\n'
r' // The implementation can be found on this page.\n\n'
r' // Create your code string here\n'
r' codeString.append(`Use string literals when ${regex} interpolating ${flags} data`);\n'
r' \n'
r' return codeString.toString();\n'
r' }\n\n'
r'}\n\n'
r'export default MyNewLangauge;'), flags=re.MULTILINE)
test_str = ("https://google.com`<Field className=\"flex flex-col p-1\">\n"
" <Label>\n"
" I agree to the{' '}\n"
" <a href=\"https://google.com\" target=\"_blank\" className=\"underline\">\n"
" terms and conditions\n"
" </a>\n"
" </Label>\n"
" <Input type=\"checkbox\" />\n"
"</Field>`gm")
subst = "/You have bound GoPlus Security Sentinel. Bound address: 0x8baa0e5a9f879ef40d55b7da808d94aca314742c/gm"
result = regex.sub(subst, test_str)
if result:
print(result)
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