1

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
  • 1
    I am already seeking an answer to this question here. No one has provided one.
    – Adrian Larson
    Commented Jul 8, 2016 at 18:16

1 Answer 1

2

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]*')
)
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .