inverted subpattern

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
JoeBlack
Posts: 2
Joined: Tue May 07, 2013 6:07 pm

inverted subpattern

Post 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.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: inverted subpattern

Post 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.
Regards,

Simon Carter, https://www.DataMystic.com
https://www.JadeDiabetes.com - Insulin dose calculator for Type 1 diabetes
https://www.DownloadPipe.com - 250,000 free software downloads
JoeBlack
Posts: 2
Joined: Tue May 07, 2013 6:07 pm

Re: inverted subpattern

Post 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.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: inverted subpattern

Post by DataMystic Support »

Yes, I think the (?! ... ) syntax is intended for a literal string, not a reference.
Regards,

Simon Carter, https://www.DataMystic.com
https://www.JadeDiabetes.com - Insulin dose calculator for Type 1 diabetes
https://www.DownloadPipe.com - 250,000 free software downloads
Post Reply