Reputation: 2617
I'm trying my hand at regex again. In particular, using a backreference to found text in the replace string in the EditPad text editor.
Subject:
Product1 Desc,12 PIN,GradeA Qty Price
Product2 Desc,28 PIN,GradeA Qty Price
Goal:
Since the text is currently space-separated, I need to replace 12 PIN
with 12||PIN
, and 28 PIN
with 28||PIN
.
What I'm trying:
[(0-9)]+[(\s)]PIN
seems to be finding what I want just fine.
When I try to replace with backrefereces, though, the only one I can get to work is \0
.
For example, using \0||PIN
as my replace gives me 12 PIN||PIN
.
When I try to replace with \1||PIN
, however, it gives ||PIN
.
What am I missing?
Upvotes: 1
Views: 754
Reputation: 13363
I could have sworn that I saw a previous poster answer this...
Using this as your find string:
([0-9]+)[\s]*PIN
and this as your replace string:
\1||PIN
should do it.
Upvotes: 1