bukkit - How to ignore case in replace method java -
this question has answer here:
alright trying check , see if string exists don't know case it's going in how use in method?
here code
if (!p.haspermission("core.chat.curse")){ string message = e.getmessage().tostring().tolowercase().replace(" ", ""); list<string> cursewords = manager.getcursefile().getstringlist("cursewords"); (string badword : cursewords){ badword = badword.tostring().tolowercase(); if (message.contains(badword)){ string crossout = ""; (int x = 0; x < badword.length(); x++){ crossout += "*"; } e.setmessage(e.getmessage().replace(badword, crossout)); //i need //replace ignore case here } } }
.replace
not take regex, can't use that!
how go doing this, because player can input word in case?
you want use case insensitive replacement regex so:
if (message.contains("(?i)"+badword))
Comments
Post a Comment