Effortlessly Extract Unique IP Addresses from a Huge File using Notepad++ Regex Search

Abstract: Extract unique IPv4 addresses from large text files using Notepad++ regex search and sorting.

Created: 2026-10-09 by

Use Notepad++'s Find and Replace dialog with regular expressions to isolate unique IP addresses from large text files. By matching the standard IPv4 pattern, copying results to a new document, and removing duplicates via the Sort Unique plugin or built-in sorting, you can efficiently extract clean, distinct network identifiers for analysis.

Understanding the Regex Pattern

To extract IP addresses effectively, you must first understand the structure of an IPv4 address. An IP address consists of four decimal numbers separated by periods, where each number ranges from 0 to 255. While simple patterns like \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} are easy to write, they often match invalid sequences such as 999.999.999.999. For most general log parsing tasks, however, the simpler pattern is sufficient because post-processing handles validation. The core regex pattern you will use in Notepad++ is \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b. Here is a breakdown of its components:
  • \b: Represents a word boundary. This ensures that the pattern does not match parts of longer strings, such as version numbers like 1.2.3.4.5.
  • \d{1,3}: Matches between one and three digits. This covers numbers from 0 to 999.
  • \.: Matches the literal period character separating the octets.
This pattern is robust enough for extracting IPs from server logs, firewall outputs, and configuration files. If your data contains IPv6 addresses, this specific pattern will ignore them, which is usually desired when focusing on IPv4 traffic. For more complex validation requiring strict 0-255 range checking, the regex becomes significantly more verbose and may slow down processing on huge files, so the simplified approach is recommended for performance.

Step-by-Step Extraction Process

Follow these steps to extract all IP addresses from your target file using Notepad++. Ensure you have opened the large text file in the editor before beginning.
  1. Open the Find Dialog: Press Ctrl+F to open the Find dialog box. Navigate to the "Replace" tab within this dialog. This allows you to copy matches directly without manually selecting them.
  2. Configure Search Mode: In the lower left corner, click the icon that looks like a calculator or select "Search Mode" > "Regular expression". This activates regex capabilities. Also, ensure "Wrap around" is checked if you want to search the entire document seamlessly.
  3. Enter the Pattern: In the "Find what" field, paste the pattern: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b. Leave the "Replace with" field empty if you only intend to view the matches, or keep it empty to preserve original formatting during replacement.
  4. Execute Find All: Click "Find All in New Document". This action creates a new tab containing every instance of the matched pattern. This is crucial because it isolates the IPs from the surrounding context, leaving only the raw addresses.
If the file is extremely large, clicking "Find All" might consume significant memory. In such cases, consider using the "Find in Files" feature if you are searching across multiple documents, but for a single huge file, the method above is standard. You can also use the "Count" feature to see how many matches were found before creating the new document.

Removing Duplicate Entries

The initial extraction step provides a list of all IP addresses, including duplicates. To get a unique set, you need to sort and remove these repetitions. Notepad++ offers two primary ways to achieve this. Method 1: Using the Sort Plugin Many users install the "NppSort" plugin, which adds sorting commands to the Edit menu. If you have this plugin installed:
  • Select all text in the new document (press Ctrl+A).
  • Go to Edit > NppSort > Remove Duplicates.
  • This command instantly deletes any line that appears more than once, leaving only unique entries sorted alphabetically.
Method 2: Built-in Sorting If you do not have plugins installed, you can use the native sorting feature combined with manual deletion or a second regex pass.
  • Select all text (Ctrl+A).
  • Go to Edit > Line Operations > Sort Lines Lexicographically Ascending.
  • Once sorted, duplicate lines are adjacent. You can then use another regex find-and-replace to collapse consecutive identical lines, though this is more complex.
For most users, installing the NppSort plugin is the fastest workflow. It integrates deeply with the editor and handles large datasets efficiently. Note that sorting changes the order of IPs; if you need to maintain the original frequency count, you should use the "Column Editor" or export to CSV for further analysis in Excel or Python instead of relying solely on text editors.

Handling Edge Cases and Validation

Sometimes, extracted IPs may include leading zeros (e.g., 192.168.001.001) or be part of larger numeric strings. The word boundary \b helps prevent matching inside larger numbers, but it does not validate the octet range. If you encounter IPs embedded in version strings or other non-standard formats, you may need to adjust the regex to exclude specific contexts. Additionally, be aware that some logs might contain truncated IPs or partial addresses. Always review a sample of the extracted data in the new document to ensure accuracy. If you notice false positives, refine the regex to add stricter boundaries or negative lookbehinds/lookaheads. For example, using (? explicitly prevents matching if preceded or followed by a digit, offering tighter control than \b in certain edge cases. For related text manipulation tasks, such as cleaning up the source data before extraction, you might find it useful to learn about RegEx Replacement in Notepad++: A Comprehensive Guide. This resource details advanced replacement strategies that can preprocess your logs, making the extraction phase cleaner and faster. Similarly, understanding how to manage sequence lines can help if your log files contain repetitive headers that interfere with pattern matching, as discussed in How to Remove Sequence Line in Notepad++.

Frequently Asked Questions

Why does my regex match invalid IPs like 999.999.999.999?

The basic pattern \d{1,3} simply checks for one to three digits, not the valid range of 0-255. To strictly validate IPs, you would need a much longer regex that checks each octet individually. For most log analysis, filtering out obvious errors manually or using external tools is more efficient than complex regex.

Can I extract IPv6 addresses using the same method?

No, the provided pattern is specific to IPv4 format (four decimal octets). IPv6 addresses use hexadecimal characters and colons. You would need a separate regex pattern designed for IPv6, such as one matching groups of hex digits separated by colons, to extract those addresses.

What if the IP addresses are not on separate lines?

The "Find All in New Document" function places each match on a new line regardless of their position in the original file. This automatically normalizes the output into a vertical list, making it easy to sort and deduplicate. If you need horizontal lists, you would need to replace newlines with spaces after extraction.

How do I handle case sensitivity in IP extraction?

IP addresses consist of numbers and periods, so case sensitivity is irrelevant for the extraction itself. However, if you are searching for hostnames associated with these IPs, you should ensure the "Match case" option is unchecked in the Find dialog to capture variations like HOST vs host.

Is there a limit to the file size Notepad++ can handle?

Notepad++ can handle very large files, limited primarily by your system's RAM. For files exceeding several gigabytes, performance may degrade, and the "Find All" operation might take considerable time. In such scenarios, using command-line tools like grep or splitting the file into smaller chunks is recommended.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More