【问题标题】:How to use find and replace wildcards in SSMS?如何在 SSMS 中使用查找和替换通配符?
【发布时间】:2014-09-03 21:16:58
【问题描述】:

所以我有类似的东西:

Price1
Price2
Price3

我想对它们进行查找和替换,所以最终结果是这样的:

COALESCE(Price1, 0)
COALESCE(Price2, 0)
COALESCE(Price3, 0)

我试过用这个:

Find what: Price.
Replace with: coalesce(Price., 0)

结果是:

COALESCE(Price.,0)

我已进入查找选项并选中“使用:正则表达式”。

我做错了什么?

【问题讨论】:

    标签: regex wildcard ssms ssms-2012


    【解决方案1】:

    将 Coalesce(Price.,0) 替换为 Coalesce(\0,0) 就可以了。

    【讨论】:

      【解决方案2】:

      您必须使用捕获组,并在替换中使用捕获组内容。

      你可以使用这个正则表达式:

      (Price\d+)
      

      Working demo

      检查替换部分捕获组内容的使用情况...

      【讨论】:

      • 在 Microsoft SQL Server Management Studio 2012 (11.0.2100.60) 中不起作用。这有效:find: (Price[0-9]+) replace: COALESCE(\0, 0).
      猜你喜欢
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-22
      • 1970-01-01
      • 2020-10-29
      • 2023-04-04
      • 2018-07-04
      相关资源
      最近更新 更多