Forum Discussion
Regular Expression to Force Parameter to be in IP Format
[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
If f5 supports perl regexes, you can simplify it with
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
The important difference between this and the previous poster's regex is it allows each octet in the ip (the octet is the 0-255 number) to be 1-3 digits. Most systems don't 0-pad the octets into 3 digit numbers, so you need this range.
This regex isn't perfect. It does not force the numbers to be 0-255 ( would match) but normally that is not a problem. However, you might need a more precise solution, for example, if you're trying to protect a parameter that lacks data validation. It probably is possible to write such a regex (I would try look-aheads), but it would be very complex and difficult for others to understand. I would advise against a regex in such a case.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com