Page 1 of 1

inverted subpattern

Posted: Tue May 07, 2013 6:17 pm
by JoeBlack
Hello.

I need to find lines containing different numbers at the end. Numbers must not be equal. For example:

Code: Select all

anyword  33
anyword  45
This regexp is not working.

Code: Select all

anyword\s+(\d+)\s+anyword\s+(?!\1)
I can find lines with equal numbers:

Code: Select all

anyword\s+(\d+)\s+anyword\s+\1
But how to find lines with different numbers?

And more one question.

Is there an option which could replace found pattern with counter? Counter is a variable that changes in increment of one in every replace. The initial value equals to zero. Seen this option in another software.

Re: inverted subpattern

Posted: Mon May 13, 2013 9:56 am
by DataMystic Support
I agree that it looks like it should work. I also tried it in another application that uses the PCRE engine, and it also does not work, so perhaps it is a failing of the PCRE engine. Have you tried any other tools?

For counting matches, add a VBScript subfilter to your search/replace - it will get passed the replacement and can make changes to it, such as adding a counter value.

Re: inverted subpattern

Posted: Thu May 16, 2013 5:35 am
by JoeBlack
I tried another tools and online services without success.

I used advasar for counting and replacing. Its very old tool and not supported anymore. BTW it have some interesting options. You can check it.

Re: inverted subpattern

Posted: Thu May 16, 2013 10:05 am
by DataMystic Support
Yes, I think the (?! ... ) syntax is intended for a literal string, not a reference.