Skip to content
Permalink
Browse files

Added Hashtag command

  • Loading branch information...
Ghost-Programmer committed Apr 14, 2019
1 parent b4d941f commit 16c3c4948e1bc8007ed1ae4ebe7d4649038cc92b
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/name/mymiller/extensions/lang/AdvancedString.java
@@ -26,10 +26,14 @@
import java.nio.charset.Charset;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import javax.swing.text.html.HTMLEditorKit;
@@ -434,6 +438,19 @@ public void handleText(final char[] text, final int pos) {
this.string = buffer.toString();
}

/**
*
* @return List of hastags contained in the string.
*/
public List<AdvancedString> hashTags() {
final String[] split = this.string.split(" ");
if ((split == null) || (split.length == 0)) {
return Collections.emptyList();
}
return Arrays.stream(split).filter(tag -> tag.startsWith("#")).map(tag -> new AdvancedString(tag))
.collect(Collectors.toList());
}

/**
* @param ch a character (Unicode code point).
* @return the index of the first occurrence of the character in the character

0 comments on commit 16c3c49

Please sign in to comment.
You can’t perform that action at this time.