I am a PHP developer and it has been only a few months since I started learning Java. Here, I have a function in PHP to retrieve the hashtags from a string.
{
preg_match_all('/(^|[^a-z0-9_])#([a-z0-9_]+)/i', $text, $matchedHashtags);
$hashtag = '';
if (!empty($matchedHashtags[0])) {
foreach ($matchedHashtags[0] as $match) {
$hashtag .= preg_replace("/[^a-z0-9]+/i", "", $match) . ',';
}
}
return rtrim($hashtag, ',');
}
This function returns a new strings containing the hashtags, separated by a comma. My question is, how to achieve this exact function in java? Regards.