Wrap URL within a string with a href tags using Coldfusion

做~自己de王妃 提交于 2019-12-20 03:05:41

问题


I have a Coldfusion site that is pulling in a feed that contains urls. I have some control over the urls so I know they will always start with http://. I want to wrap those urls in a href tags so they are clickable but I'm having trouble figuring it out. Any info you guys could give me would be amazing.

Eric


回答1:


This should work:

<cfset myStr = REReplaceNoCase(myStr, "(\bhttp://[a-z0-9\.\-_:~@##%&/?+=]+)", "<a href=""\1"">\1</a>", "all") />



回答2:


Far more better approach:

http://www.bennadel.com/blog/487-Using-Verbose-Regular-Expressions-To-Explain-Url-Auto-Linking-In-ColdFusion.htm



来源:https://stackoverflow.com/questions/1267637/wrap-url-within-a-string-with-a-href-tags-using-coldfusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!