douduan9391 2014-10-25 09:47
浏览 1524
已采纳

Golang正则表达式以查找字符串中的网址

I am tring to find all links in a string and then hyperlink them
like this js lib https://github.com/bryanwoods/autolink-js

i tried to use alot of regex but i always got too many errors
http://play.golang.org/p/iQiccXvFiB
i don't know if go has a different regex syntax

so, what regex that works in go that is good to match urls in strings

thanks

  • 写回答

2条回答 默认 最新

  • doujue6196 2014-10-25 10:52
    关注

    Use back-ticks instead of double-quotes for your string literals. Back-slashes inside double-quotes start escape sequences, which you don't need/want for this use case.

    Additionally, how did you expect this to work?

    "<a href="$0">$0</a>"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码