0

I am trying to use the below regex in my validation rule.

OR(

REGEX(BillingStreet ,'(.+\n){4,}'),

REGEX(BillingStreet, '.{60,}')

)

I am attempting to force the street address to not allow more than three lines and to also disallow any line from being 60 characters long.

It does not seem to be firing at all even though RegExr validates it. Any salesforce specifics I need to know or is my rule wrong?

Thanks!

  • 1
    I am already seeking an answer to this question here. No one has provided one. – Adrian Larson Jul 8 '16 at 18:16
0

The REGEX() function only returns true if the regular expression matches the entire string. So you have to add .* or [\\S\\s]* before and after the pattern you're looking for. Where .* will not match carriage returns and [\\S\\s]* will.

This should do the trick to limit the input to three lines of no more than 60 characters each:

OR(
    REGEX(BillingStreet, '(.*\r\n){3,}.*'),
    REGEX(BillingStreet, '[\\s\\S]*.{61,}[\\s\\S]*')
)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.