Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String nextWordOrSeparator(String text, int position,
- Set<Character> separators) {
- assert text != null : "Violation of: text is not null";
- assert separators != null : "Violation of: separators is not null";
- assert 0 <= position : "Violation of: 0 <= position";
- assert position < text.length() : "Violation of: position < |text|";
- String answer = "";
- int endPosition = position + 1;
- boolean wordOrSep = separators.contains(text.charAt(position));
- while (endPosition < text.length() && (wordOrSep == separators
- .contains(text.charAt(endPosition)))) {
- endPosition++;
- }
- answer = text.substring(position, endPosition);
- return answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement