Skip to content

Instantly share code, notes, and snippets.

@trentrand
trentrand / Regex for SMS URI (RFC-5724)
Last active March 1, 2022 03:48
Regular expression for validating 'sms' uri scheme. (RFC 5724)[https://tools.ietf.org/html/rfc5724]
This protocol is well-defined by [RFC 5724][1] with the formal definition:
sms-uri = scheme ":" sms-hier-part [ "?" sms-fields ]
scheme = "sms"
sms-hier-part = sms-recipient *( "," sms-recipient )
sms-recipient = telephone-subscriber ; defined in RFC 3966
sms-fields = sms-field *( "&" sms-field )
sms-field = sms-field-name "=" escaped-value
sms-field-name = "body" / sms-field-ext ; "body" MUST only appear once
sms-field-ext = 1*( unreserved )