Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Style of hashtag based on JSON from Twitter-API

I am using Twitter-API to get tweets in JSON. Now I would like to style my tweets like making hashtags with other color than text.

I don't know how to style text which start with #.

Now I get JSON like this:

Array
    (
        [0] => Array
        (
        [created_at] => Fri Dec 21 08:39:05 +0000 2018]
        [id] => 1076034307246960640
        [id_str] => 1076034307246960640
        [text] => @em_finland'in #EuroopanSuunta-podcastissa tällä kertaa jutustelemassa meikäläinen ja MEP @HennaVirkkunen. Aiheina…
        )
    )

I want to change the color of hashtags (tag and text - #EuroopanSuunta in the example ) but I don't know how to get all of them within the text.

EDIT: After @Yaakov Ainspan comment I made this in jQuery:

var oldHtml = $(".twitter_text1").html();
var newHtml = oldHtml.replace(new RegExp(/(\W(\#[a-zA-Z]+\b))/g), "<span class='highlight'>$1</span>");

And that's work. Closed.

Comments