Consider the following regex:
([a-zA-Z])([a-zA-Z]?)/([a-zA-Z])([a-zA-Z]?)
If the text is: a/b
the capturing groups will be:
/1 'a'
/2 ''
/3 'b'
/4 ''
And if the text is: aa/b
the capturing groups will be:
/1 'a'
/2 'a'
/3 'b'
/4 ''
Suppose, I want to find and replace this string in Notepad++ such that if /2
or /4
are empty (as in the first case above), I prepend c
.
So, the text a/b
becomes ca/cb
.
And the text aa/b
becomes aa/cb
I use the following regex for replacing:
(?(2)12|01)/(?(4)34|03)
But Notepad++ is treating ?
literally in this case, and not as a conditional identifier. Any idea what am I doing wrong?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…