# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"[幹乾淦贛干肏操糙去草塞賽]?[林賃吝零靈齡拎恁你他她它祂牠]([馬马量梁良糧涼娘妹媽]|老[師蘇詩屍濕溼]|奶奶|祖?(嬤|媽|罵))(的|樂|叻|垃|勒|咧|([基唧雞機激][掰歪]))?|[靠尻哭][杯倍背貝輩悖北盃悲卑揹腰邀妖夭幺么]|([基唧雞機激](車|[教轎窖嶠叫較趴葩]|[掰歪]))|(([魯盧擄虜盧爐]|[假呷吃甲賈卡]|[衝沖充銃欉謥]?[三殺沙砂啥])[小洨曉])|(破[麻目])|([俗卒][仔臘辣])|[賤屌肏操糙]|(幹(?![麻嘛嗎]|(啥|[蛇神什甚]麼|[好壞]事)))|(靠(?!在|的|他|你|妳|她))|([林賃吝拎恁你][霸爸北背])|([懶藍覽攬欖][教轎窖嶠叫較趴葩])|([白北度杜渡肚虎唬][爛濫纜藍覽懶])|(智[缺障仗丈瘴])|(去你的)|((?i)GG\s?IN\s?IN)|(想[樓揉])|(ㄈㄈ尺)|((?i)ccr|fuck|hell|shit|ass(hole)?|idiot|damn|bitch|phycho|bastard|Whore|Slut)"
test_str = ("幹\n"
"幹嘛\n"
"幹麻\n"
"幹甚麼好事\n"
"幹他媽的\n"
"幹你娘\n"
"乾 \n"
"乾淨\n"
"乾林老師\n"
"靠 \n"
"靠北\n"
"靠你了\n\n"
"靠北邊\n"
"靠杯\n"
"靠背\n"
"靠盃\n"
"靠腰\n"
"靠夭\n"
"哭夭\n"
"幹靈糧\n"
"去你的\n"
"去你媽的\n\n"
"林北\n"
"恁北\n"
"恁娘\n"
"恁祖媽\n"
"機掰\n"
"賤\n"
"俗辣\n"
"他媽的\n"
"覽趴\n"
"懶趴\n"
"北爛\n"
"盧小\n"
"魯洨\n"
"色龜\n"
"肚爛\n"
"放屁\n"
"屁股\n"
"屌\n"
"啥小\n"
"三小\n"
"操\n"
"屁\n"
"唬爛\n"
"龜公\n"
"他奶奶的\n"
"犯賤\n"
"機車\n"
"智缺\n"
"你娘卡好\n"
"林老師\n"
"破麻\n"
"賽\n"
"操卒仔\n"
"操機歪\n"
"糙機掰\n"
"無懶趴\n"
"卡小\n"
"吃小\n"
"死魚眼\n"
"炭甲查某\n"
"糙你妹\n"
"GGININ\n"
"GG IN IN\n"
"GG IN IN DER\n"
"gginin\n"
"可惡 想揉\n"
"想揉\n"
"ㄈㄈ尺\n\n\n"
"英文原生:\n"
"CCR\n"
"Fuck off\n"
"Fuck\n"
"mother fucker\n"
"You SOB\n"
"son of a bitch\n"
"Go to hell\n"
"Shit-head\n"
"Asshole\n"
"You beast\n"
"Shit\n"
"fart\n"
"Idiot\n"
"damn it \n"
"God damn\n"
"God damn it\n"
"hypocrite\n"
"ass hole\n"
"ass licker\n"
"bitch \n"
"phycho\n"
"bastard\n"
"Whore\n"
"Slut\n"
"Shit-head\n")
matches = re.finditer(regex, test_str)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# 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