我在sql server 2012中获得的数据包含带有链接<a href="test/test">test </a>
的文本,但没有目标我需要为字符串数据添加目标。我需要为此创建一个用户定义的函数。是否有人为此提供任何示例代码。
示例文字 -
If you've ever thought one of your text message threads was so good it deserved to be published, you may be on to something.view. <a href="/apple/sdffsd/sdffs">njkhj </a> In future iterations, users will be able to post .<br><br>You may update your email address at any time by going to <a href="/apple/fafasdf/sdfsdf">sdffsd</a>. Our whole goal is to have the reader go through an entire narrative arc in five minutes and consume it in a way that's native to mobile," says Gupta go to <a href="/a/s/sdfsf"> sdfsdf </a> which is one of my favorite books, is told as letters back and forth between the two main
答案 0 :(得分:1)
我认为一个简单的替换可以解决这个问题
Declare @String varchar(max) = 'Some large text with a <a href="test/test">link</a> to content'
Select Replace(@String,' href=','_target="blank" href=')
返回
(No column name)
Some large text with a <a _target="blank" href="test/test">link</a> to content
答案 1 :(得分:0)
我们也可以使用
#include <memory>
#include <set>
namespace std
{
template<typename T>
struct dereference_less
{
constexpr bool operator ()(const T& _lhs, const T& _rhs) const
{
return *_lhs < *_rhs;
}
};
}
int main()
{
using key_type = std::shared_ptr<int>;
std::set<key_type, std::dereference_less<key_type>> mySet;
}