0

So I have something like:

Price1
Price2
Price3

And I'd like to do a Find and Replace on them so the end result is this:

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

I tried using this:

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

The result is:

COALESCE(Price.,0)

I've gone into Find Options and checked "Use: Regular Expressions".

What did I do wrong?

dotnetN00b
  • 5,021
  • 13
  • 62
  • 95

2 Answers2

1

You have to use capturing groups and in the replace use the capture group content.

You can use this regex:

(Price\d+)

Working demo

Check the substitution section the capture group content usage...

enter image description here

Federico Piazza
  • 30,085
  • 15
  • 87
  • 123
  • Doesn't work in Microsoft SQL Server Management Studio 2012 (11.0.2100.60). This works: **find:** `(Price[0-9]+)` **replace:** `COALESCE(\0, 0)`. – jumxozizi Jan 26 '16 at 13:58
1

Replace Coalesce(Price.,0) with Coalesce(\0,0) and you'll be good to go.