【发布时间】:2021-07-08 19:02:24
【问题描述】:
我正在使用 SQL Server 尝试替换字符串中每个重复出现的“[BACKSPACE]”和单词 [BACKSPACE] 之前的字符,以模仿退格键的作用。
这是我当前的字符串:
"This is a string that I would like to d[BACKSPACE]correct and see if I could make it %[BACKSPACE] cleaner by removing the word and $[BACKSPACE] character before the backspace."
这就是我想说的:
"This is a string that I would like to correct and see if I could make it cleaner by removing the word and character before the backspace."
让我更清楚地说明这一点。在上面的示例字符串中,$ 和 % 符号仅用作需要删除的字符示例,因为它们位于我要替换的 [BACKSPACE] 单词之前。
这是另一个之前的例子:
The dog likq[BACKSPACE]es it's owner
我想将其编辑为:
The dog likes it's owner
最后一个例子是:
I am frequesn[BACKSPACE][BACKSPACE]nlt[BACKSPACE][BACKSPACE]tly surprised
我想将其编辑为:
I am frequently surprised
【问题讨论】:
-
支持正则表达式替换的语言在这里会好得多。另外,您说它只删除字符 before,但这仅适用于
'd[BACKSPACE]'。对于%[BACKSPACE]和$[BACKSPACE],它还会先删除前导空格。 -
您的 SQL Server 版本是多少?
-
@YitzhakKhabinsky SQL Server 2008 R2 SP3
-
根据问题指南,请展示您的尝试并告诉我们您发现了什么(在本网站或其他地方)以及为什么它不能满足您的需求。
标签: sql sql-server tsql string-concatenation