Reputation: 154
i want to ignore the .
in quotation marks. what the regex should i use?
example sentences :
String sentence = "i love you. \"i'm sorry. but love someone else,\" he said to me. ";
there are three .
but i want to ignore the .
in quotation marks in order to the sum of sentence is two.
my code and some regex that i have :
public static String[] ignoreWord(String word){
String [] arrWords = word.replaceAll(", *| , *|- *| - *|\\( *| \\( *|\\) *|\\{ *| \\} *| \\} *| \\{*|\\} *", " ").split("\\. ");
return arrWords;
}
Upvotes: 3
Views: 124
Reputation: 67988
\.(?=(?:[^"]*"[^"]*")*[^"]*$)
Try this.See demo.
http://regex101.com/r/zX3tG3/1
Upvotes: 3