Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Anita Morales   on Aug 04 In Java Category.

  
Question Answered By: Pravat Jainukul   on Aug 04

> string []swear= { "swearword1", "swearword2", "swearword3"
> };

> string=" Here is some type of string a user owuld enter "

Huh?

> for(int i=0; i< swear.size(); i++)
> if(str.indexOf(swear[i])>=0)
> replace.All(swear[i], "***")

public class MyFiler {

public static void main(String args[]) {
string input = "Parse this sentance";
StringTokenizer st = new StringTokenizer(input);

while (st.hasMore()) {
String word  = st.next();
for (int i=0; i<swear.length(); i++) {
if(swear[i].equals(word)) {
word="*";
}
}
}
}
}

Share: 

 
 
Didn't find what you were looking for? Find more on Swear word filter Or get search suggestion and latest updates.


Tagged: