regex question

A place to try and solve your RegEx problems.
Post Reply
User avatar
Remon

regex question

Post 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.
User avatar
DV

Post 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.
User avatar
Remon

Post by Remon »

thank you very much!
User avatar
Fool4UAnyway

Post 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-
Post Reply