タグを説明文字列から除外し、それらをアンカー タグにしたいと考えています。タグの値を返すことができません。
私の入力は次のとおりです。
a = "this is a sample #tag and the string is having a #second tag too"
私の出力は次のようになります。
a = "this is a sample <a href="/tags/tag">#tag</a> and the string is having a <a href="/tags/second">#second</a> tag too"
これまでのところ、いくつかのマイナーなことを行うことはできますが、最終的な出力を達成することはできません. このパターン:
a.gsub(/#\S+/i, "<a href='/tags/\0'>\0</a>")
戻り値:
"this is a sample <a href='/tags/\u0000'>\u0000</a> and the string is having a <a href='/tags/\u0000'>\u0000</a> tag too"
他に何をする必要がありますか?