Page 1 of 1

regex question

Posted: Fri Feb 26, 2010 9:11 am
by Remon
DV, you seems to know regex very well.

I have a very simple question but cannot find a solution for it.

I want to add a "-" character after all numbers in a text file.

find: \d
replace: \d-
but it puts the string inside the text.

Posted: Fri Feb 26, 2010 10:50 am
by DV
You can create a capturing group-

Regex:(\d)
Replace:$1-

This will put a - after each number, but if you have a number like 12 it will become 1-2-
I guess it depends on what you want.

Posted: Fri Feb 26, 2010 11:35 am
by Remon
thank you very much!

Posted: Fri Feb 26, 2010 11:18 pm
by Fool4UAnyway
I guess he means (real) numbers, not individual digits.

Find: (\d+)
Replace: $1-

In Notepad++, yes, you have to check the regular expression radio button (Ctrl+H) or checkbox (Ctrl+R).

Find: (d+)
Replace: \1-