This is a basic instruction on how to search for any texts that resembles IP addresses in all files within a folder using Visual Studio Code.
Although it’s not going to be a perfect solution, we’re going to use Regex to do the search. And we’re going to want to get all invalid IPs as well, so it’s not 100% precise. Here, we want to error on the side of getting a bit too much rather than too little.
Steps
-
Launch Visual Studio Code and open the folder where you want to search the files with IP addresses.
-
We want to search for all files within this folder, so using a keyboard shortcut, press CTRL+SHIFT+F for PC or CMD+SHIFT+F for Mac.
We’re going to use the following pattern:
((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}
IMPORTANT: This is very easy to miss. Make sure the Use Regular Expression icon is active, otherwise the RegEx search will not work.
-
You’ll see all the files that contain anything that looks like IP addresses are listed underneath the search box on the left pane and you can click on each file to see where the IP addresses are found.
For various REGEX patterns to use to fine tune your search, just check out the link below for a more thorough explanations/discussions.
Further Reading
Validating IPv4 addresses with regexp
How to Use RegEx to Replace Text in JavaScript