I try to remove dot only from end of each word in given text. (in java) for example:
input: java html. .net node.js php. output: java html .net node.js php
for(String str : input.split(" ")) { if(str.charAt(str.len - 1) == '.') str = str.substr(0, str.len - 2); //do something with str }
I would avoid regular expressions if at all possible as they are much slower.