I know that regular expressions are limited in npp, due to the limitations in SciTE. But I was surprised today to find that * and + don't work when applied to a group.
Searching for software version numbers (e.g. 1.0.36.14 or 11.1.20090101, etc.)
Pattern: ([0-9]+)(\.[0-9]+)*
Npp: "Fail."
Even the simple pattern ([0-9])+ fails.
After thinking about it for a moment, I can see why: repetition operators on a group result in multiple groups with the same name. Other engines allow you to iterate capture groups, but I'm guessing the SciTE engine blarfs on that.
If there's a way to ignore a capture group in npp, I'm golden: (?:[0-9])+ would be the pattern in other apps.
Possible in npp/SciTE?
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I could use a little help here as well I have a list of IP's that I need to change the last octet from a number to a * but some of the ip's are listed in this manner here is a snippet
You can see the last octet is not of a stand 0-255 length. I need to search and replace my whole list of 5000+ ip's
Could you post the exact search and replace string for this I tried all the different combos listed above and I must be missing something I Hope that this makes sense
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know that regular expressions are limited in npp, due to the limitations in SciTE. But I was surprised today to find that * and + don't work when applied to a group.
Searching for software version numbers (e.g. 1.0.36.14 or 11.1.20090101, etc.)
Pattern: ([0-9]+)(\.[0-9]+)*
Npp: "Fail."
Even the simple pattern ([0-9])+ fails.
After thinking about it for a moment, I can see why: repetition operators on a group result in multiple groups with the same name. Other engines allow you to iterate capture groups, but I'm guessing the SciTE engine blarfs on that.
If there's a way to ignore a capture group in npp, I'm golden: (?:[0-9])+ would be the pattern in other apps.
Possible in npp/SciTE?
Thanks!
I could use a little help here as well I have a list of IP's that I need to change the last octet from a number to a * but some of the ip's are listed in this manner here is a snippet
110.37.52.10771
114.169.245.134
114.170.152.144
114.44.138.1560
114.44.17.96585
115.108.112.139
115.113.17.5072
115.118.193.995
115.118.97.2078
115.186.104.170
115.186.6.13164
115.186.69.9416
115.186.72.2515
115.80.67.46135
You can see the last octet is not of a stand 0-255 length. I need to search and replace my whole list of 5000+ ip's
Could you post the exact search and replace string for this I tried all the different combos listed above and I must be missing something I Hope that this makes sense
Find field:
^(\d+\.\d+\.\d+\.)\d\d\d\d+$
^ _______ Search from/for the start of a line
\d+ _____ Search for a string of digits (at least one)
\. ______ A(n absolute) dot
() ______ Grouped expression that can be use in Replace
\d\d\d\d+ Search for a string of at least 4 digits
$ _______ Search for the end of a line
Use ^ and $ if the ISP number is the _only_ text on the lines.
5000+ means at least 4 digits, which is always more than the maximum 3 used for numbers 0 - 255.
Replace field:
\1*
\1 ______ Re-place the first grouped expression
* _______ Place the asterisk instead of the 5000+ number
If you need to replace _all_ last octets, use \d+ instead of \d\d\d\d+ here also. I (may) have misread your message.
If your list _only_ exists of ISP numbers, this will take less time:
Find:
\d+$
Replace
*
It searches for the last octet only and replaces only this by the asterisk.
Thank you all very much your idea's got me to my end goal YOU ALL ROCK very much thank you .. you just took HOURS off my issue
If only there was any followup on this:
https://sourceforge.net/forum/message.php?msg_id=5712417
CChris
> Even the simple pattern ([0-9])+ fails.
Try either of the following:
[0-9]+
([0-9]+)
\d+
(\d+)
> Searching for software version numbers
> (e.g. 1.0.36.14 or 11.1.20090101, etc.)
> Pattern: ([0-9]+)(\.[0-9]+)*
Well, let's see, you want some string that contains digits and dots, but with additional requirement of a digit to start and end with, I guess.
Try the following:
\d[\.\d]+\d
If a dot is required:
\d+\.\d[\.\d]+\d
If two dots are required:
\d+\.\d[\.\d]+\d\.\d+
Of course, these regular expressions don't exclude strings with multiple consecutive dots.
You might just expand the regex to contain the exact number of dots and numbers by simply mentioning them:
\d+\.\d+\.d+\.\d+