Forum Discussion
Regular Expression to Force Parameter to be in IP Format
- natheCirrocumulusSSHSSH
- mister_paul_717NimbostratusEvery tool has a slightly different implementation of regex. I haven't tested this on F5 yet, so it might not be quite right, but give it a try. I use it ALOT on other systems.
[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, ifyou'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. - mister_paul_717NimbostratusHere is an example of a regex that should work to force the numbers to be between 0 and 255. This is just one octet - you would have to do this 4 times, with \. between each.
- mister_paul_717NimbostratusOops. Missed some parenthesis...
- SSHSSH_97332NimbostratusThanks All . where i can find guide & examples fro regular expressions ?
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