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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -