I'm trying to write a pipe that can make any words with #hashtaginto a url exactly like twitter.
This is the function in my pipes that generates converts #tags into urls.
urlifyHashtags(_text) : String {
let hashtagRegex = /^#([a-zA-Z0-9]+)/g;
let tempText = _text.replace(hashtagRegex, " <a [routerLink]=\"['/search/hash/aaa']\" routerLinkActive=\"active-link\">#$1</a>");
var hashtagRegex2 = /([^&])#([a-zA-Z0-9]+)/g;
tempText = tempText.replace(hashtagRegex2, "<a [routerLink]=\"['/search/hash/' , 'Russ']\" routerLinkActive=\"active-link\"> #$2</a>");
return tempText;
}
And this is where it goes to:
<p *ngIf="!editable" [innerHTML] ="item.body | bodyHashtag"></p>
Any help/advice much appreciated.