Regular expression updated. Now it recognizes also hashtags such as #gcube4.1.0, #gcube4.1.0gcore etc

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-util-library@132611 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-10-04 15:05:18 +00:00
parent 1cd487a832
commit 483c585f14
2 changed files with 6 additions and 7 deletions

View File

@ -38,9 +38,8 @@ public class Utils {
/**
* Hashtag regex enhanced for ticket #4937
* If you want to accept hashtags of type #X, then you will need to use ^#\\w*[.]?\\w+|\\s#\\w*[.]?\\w+
*/
private static final String HASHTAG_REGEX = "^#\\w+[.]?\\w+|\\s#\\w+[.]?\\w+";
private static final String HASHTAG_REGEX = "^#\\w+([.]?\\w+)*|\\s#\\w+([.]?\\w+)*";
/**
*

View File

@ -8,7 +8,7 @@ public class TestUnit {
//@Test
public void testHashtag() {
String text = "This is a test with hashtag #T6 and #T6.1 but also #T6. that has '.' that is useless and #T43..43 .";
String text = "This is a test with hashtag #T6 and #T6.1 but also #T6. that has '.' that is useless and #T43.43 and #gcube4.1.0gcore #gcube4.1.0";
List<String> hashtags = Utils.getHashTags(text);
System.out.println("Hashtags are " + hashtags);
}