java - Regular expression to replace words from a list by whitespaces -


I have a list of words list and a string text For example:

For example: you for example: you , is , in and etc

then, to remove them and replace them with a white space is required.

Please, how do I do this?

I think I should go to each item from the list, then check what the text contains. What regular expressions can I use to remove words (to remove)? They can be followed by white spot or ponctuation.

Expected output for this example: "Deadly Jiva, PHP, Oracle."

PS: I can not remove punctuation marks! I am using Java

Try it out:

  string text = "blah blah .. .. "; {Text = text.replaceAll ("\\ s" + word + "\\ s", "\\ s") for (string word: wordlist); // To find the word exactly in your text. } Text = text.replaceAll ("\\ s +", "\\ s");    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -