fixed hashtag regex: only one dot is allowed
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-util-library@131260 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
37eef5e954
commit
9702709ea6
|
@ -38,9 +38,9 @@ public class Utils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashtag regex enhanced for ticket #4937
|
* 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+
|
* 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+";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,12 +2,13 @@ package org.gcube.social_networking.socialutillibrary;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class TestUnit {
|
public class TestUnit {
|
||||||
|
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void testHashtag() {
|
public void testHashtag() {
|
||||||
String text = "This is a test with hashtag #T6 and #T6.1 but also #T6. that has '.' that is useless.";
|
String text = "This is a test with hashtag #T6 and #T6.1 but also #T6. that has '.' that is useless and #T43..43 .";
|
||||||
List<String> hashtags = Utils.getHashTags(text);
|
List<String> hashtags = Utils.getHashTags(text);
|
||||||
System.out.println("Hashtags are " + hashtags);
|
System.out.println("Hashtags are " + hashtags);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue