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:
parent
1cd487a832
commit
483c585f14
|
@ -35,12 +35,11 @@ public class Utils {
|
|||
* logger
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(Utils.class);
|
||||
|
||||
|
||||
/**
|
||||
* 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+)*";
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -253,8 +252,8 @@ public class Utils {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* convert the mentioned people in HTML anchor and also Encode the params Base64
|
||||
* @param escapedFeedText
|
||||
* @param taggedPeople
|
||||
|
@ -264,7 +263,7 @@ public class Utils {
|
|||
String pageToRedirectURL = "";
|
||||
String httpGETAttrName = "";
|
||||
String httpGETAttrValue ="";
|
||||
|
||||
|
||||
for (ItemBean tagged : taggedPeople) {
|
||||
if (! tagged.isItemGroup()) {
|
||||
pageToRedirectURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue