I\'m trying to use a RegularexpressionValidator to match an IP address (with possible wildcards) for an IP filtering system.
I\'m using the following Regex:
My answer is general for .NET, not RegularExpressionValidator-specific.
Regex string for IP matching (use ExplicitCapture to avoid useless capturing and keep RE concise):
"\\b0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})(\\.0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})){3}\\b"
Depending on particular use case you may want to add appropriate anchors, i.e. \A or ^ at the beginning and \Z or $ at the end. Then you can remove word-boundaries requirement: \b.
(Remember about doubling \ inside the string)