-2

We are trying to Limit number of recipients in To, CC and Bcc fields using following regular expression, however not functioning as required. Please help.

Full headers / Recipient headers matches regex - ([^@]*@){3,}

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268

2 Answers2

0

Without much to go on in your original post you I offer this rather bleak answer which will match 1, 2 or 3 email addresses that adhere to RFC 5322:

(?:(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?: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]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])[,;\s]*){1,3}

Regular expression visualization

Note: right click the image and select Open in new tab.

Ro Yo Mi
  • 14,790
  • 5
  • 35
  • 43
0

This is what I use against "Recipients header" in a Compliance policy in Google.

^[^@](\@[^|]){6,}$