function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CKGCKG 

Valid IP Address, VAlidation rule

Hi,

I am working on IP Adress field. i am trying out a validation rule for IP format. below is the formula i used

 

NOT(
REGEX(  CBR_WAN_IP__c ,
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)
{3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ))

 

It shows up a message saying Error: Syntax error. Missing " , not sure y, pl help sort out this

 

Thanks in Advance

CK

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

This formula :

 

NOT(
REGEX( ankit__IP_ADDRESS__c,
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
))

 is working fine for me. Just try again copying it form here and replace the "ankit__IP_ADDRESS__c" with your IP address field API name.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

All Answers

Shashikant SharmaShashikant Sharma

try this

 

^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.
([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$

 

CKGCKG

I tried using it, it poped a error message again Error: Syntax error. Found '^', the data type i used is number for the field, have tried it on text field also, there's no change, every time error pops up

Ankit AroraAnkit Arora

This formula :

 

NOT(
REGEX( ankit__IP_ADDRESS__c,
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
))

 is working fine for me. Just try again copying it form here and replace the "ankit__IP_ADDRESS__c" with your IP address field API name.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This was selected as the best answer
CKGCKG

Thanks a lot ... :-)

Ryan William SchorrRyan William Schorr
For those using Ankit's amazing regex above, don't forget to replace "ankit__IP_ADDRESS__c" with the API Name of the field you're validating.