Wrap URL within a string with a href tags using Coldfusion

后端 未结 2 1162
自闭症患者
自闭症患者 2021-01-21 12:42

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

相关标签:
2条回答
  • 2021-01-21 13:20

    This should work:

    <cfset myStr = REReplaceNoCase(myStr, "(\bhttp://[a-z0-9\.\-_:~@##%&/?+=]+)", "<a href=""\1"">\1</a>", "all") />
    
    0 讨论(0)
  • 2021-01-21 13:23

    Far more better approach:

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

    0 讨论(0)
提交回复
热议问题