# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"[^0-9a-z]?(bikini|b[i|e]rah[i|e]|b[o|u]g[i|e]l|[men|di]?cabul[i]?|cialis|[dic|menc|menyu]?umbu[i]?|dildo|[ng]?ent[o|i]t|ereksi|eroti[k|c]|gay|jemb[u|e]t|judi|[c|k]ondom|kontol|kunam|lesb[o|ian]|libido|lucah|memek|[dip|pem]?erkosa|miras|penis|pepek|porno|puting|rog[o|e]l|seks|se[k|n]sual|sex]|telanjang|telugu|tetek|titit|toge[l]?|tocil|vagina|viagra|orgasm[e]?|kemaluan|k[e]?lamin|[ngen|jan]cuk)[^0-9a-z]"
test_str = "persaingan dua pembalap mercedes kembali terjadi pada balapan gp formula 1 monaco. nico rosberg akhirnya sukses memutus rangkaian kemenangan rekan satu timnya, lewis hamilton yang finis di posisi kedua pada balapan yang digelar seksual seks sensual "
subst = "###BAD###"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.IGNORECASE | re.MULTILINE | re.DOTALL)
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