On 10/28/2006 10:18:05 AM, Christian Ziemski wrote:
>On Sun, 22 Oct 2006 20:40:00 -0400, Ian
>Binnie wrote:
>
>>I have been using regexp quite a lot lately, but have some problems.
>>
>>One example, I am trying to search lines like the following, and replace the
>>2nd Mary.
>>[...]
>
>Ian:
>
>I'm looking at your example for some
>time now, trying to understand
>it. But I'm not able to.
>
>The complete line seems to be changed to
>itself but without the word
>"Mary"?!?
>
>If you would explain your plan a bit
>more detailed I'll try to help.
>
Replace("^(\.+\s[1-9]\s\b([A-Z][a-z]+)\b.+)\b\2\b", "\1", REGEXP|NOERR|CONFIRM)
Replace("
^ begin of line
( group 1
\.+\s[1-9]\s find leader i.e. repeated . space digit space
\b([A-Z][a-z]+)\b find Name on word boundaries => group 2
.+ match all
) end group 1
\b\2\b match group 2 on word boundaries
The command is designed to match a line containing a Name, up to a repeat of the name, then delete the 2nd name (by replacing the found string with group 1 - up to the repeated name.
Unfortunately if the line contains more than 2 copies of the name, it does not match the 1st repeat, but the last.
My question is about the Regexp behaviour, which is not what I would expect.
I am not trying to just solve this problem, I could do this many ways e.g. a loop which copied the found Name into a text register.
|
|