Let's talk about this suspicious ip address, 58.63.144.170. It is said to be a mentally retarded spider. God bless it and go to hell.
Friends who have read apache logs should know that each line of apache access logs starts with the visitor's ip address. Because the logs are large, I use ultraedit to view them. When using ultraedit, you must note that there are two types of regular expressions. One is compliant with the perl specification, and the other is the built-in ut by default. The writing method is special. The regular expressions used in this article are perl Compatible. In ut, this option can be modified in "advanced-> Configuration-> Search-> Regular Expression Engine.
After some thought, I found that the regular expression I have mastered does not seem to be able to directly Delete the usage of a specified string "not included. After thinking about it, write a string containing the specified string: ^ (58.63.144.170 ). * $. To test this function, you can find the rows containing the specified ip address. The next step is to retain these rows and delete other rows. After N attempts, I finally gave up the idea of deleting a row without this ip address. What should we do? Step back! Since it cannot be deleted directly, let's take a look. Although you cannot directly Delete rows that do not contain the specified string, I will write the deletion of regular expressions that do not contain the specified character :)
The line containing the specified ip address is marked first. The ut replacement function is used here. Row to be searched: ^ (58.63.144.170 )(.*). Because each line of the log starts with a number, I select '%' as a special symbol for the flag. The regular to be replaced with: % $1 $2. After all replacement, the line containing the specified ip address becomes like this: % 58.63.144.170 ....... Next, we will delete the row whose header is not '%' and find ^ [^ %]. *. The replacement is null. Execute replace all. Only the lines starting with '58. 63.144.170' are left in the log! Wait. The remaining blank rows are too ugly. Let's take them out and look for ^ [\ r \ n] * $. The replacement is null. Execute all replace, the world is finally quiet...
In fact, the regular expressions used in this article are very basic. Although the regular expressions cannot be written to delete the rows containing the specified string, they are actually required in the loop, and it looks clearer. Sometimes it may not be a better choice to take a step back.