如何用JavaScript替换twitter风格的#hashtags?
即。
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_fragment_dashboardhome"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</android.support.v7.widget.RecyclerView>
应该成为this is a #hashtag
。
对于PHP:Parse text for hashtags and replace with links using php
答案 0 :(得分:3)
t = 'this is a #hashtag'
t.replace(/#(\w+)/g, '<a href="tag/$1">#$1</a>')
给出
this is a <a href="tag/hashtag">#hashtag</a>