Short and sweet:
10\.\d{1,3}\.\d{1,3}\.248
will get you pretty close, and is relatively simple.
- Escape the dot with
\.
to prevent it from matching any character
- Use
\d
to match any digit character
- Use
{1,3}
to limit the number of consecutive digits to 1, 2, or 3
More complicated, but more exact:
To only match numbers between 0 and 255, you could replace \d{1,3}
with ([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])
:
10\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.248
- or -
10(\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])){2}\.248
Testing/developing regex patterns in the future
There are a lot of regex tester websites out there. I personally use RexexHero.net since I develop .Net applications, but there are other more generic options too such as regexpal.com.