What are the allowed character in snapchat username
Asked Answered
C

2

10

I have been unable to find what the allowed characters are while creating a shapchat (https://www.snapchat.com/) username. Can anyone here share their knowledge regarding this?

Context: I am creating a username validation system.

N.B. I have tried support.snapchat.com - but it provides no information regarding the allowed characters in a username.

Coeternity answered 2/10, 2016 at 17:44 Comment(4)
This is off topic here. This platform is about programing not about using applicationsRetuse
Why negative please? who knows is not a big deal for him.Coeternity
Then guide me. I found snapchat tag here and i think there is a relation with programming since i am creating a username validating system.Coeternity
why down vote? I found questions like this here, even upvoted 26 times favorited 10 times e.g. #15470680Coeternity
E
21

From page 5 of Snapchat's law enforcement guide:


Snapchat usernames:

  • Must be 3-15 characters long
  • Can’t contain spaces
  • Must begin with a letter and ends with a number or letter
  • Can only contain latin letters, numbers, and one special character of the following allowed set: hyphen ( - ), underscore ( _ ), and period ( . )
  • Can’t contain emojis or other symbols such as @, $, #, etc.
Erna answered 31/1, 2017 at 13:58 Comment(6)
I agree. I have read the Snap Inc. Law Enforcement Guide and this should be the accepted answer. Unfortunately, OP has been inactive since Apr 2017, so this question may never have an accepted answer.Carlotacarlotta
In case anyone ends up here looking to validate snapchat user names, the regex /^[a-zA-Z][\w-_.]{1,13}[\w]$/ will match a valid Snapchat username, according to the above rules. Something to look out for though, Instagram also prevents you from using two periods together (..) - I'm not sure if Snapchat enforces this tooAustrasia
Be careful about using \w as that may well match non-ASCII characters like emojis, which are expressly forbidden.Celanese
A small edit to Jamie's comment. Considering the minimum characters (3) and maximum (15), the regex would be /^[a-zA-Z][\w-_.]{3,15}[\w]$/Guglielmo
The regexes provided by @Jamie-FenrirDigitalLtd and Zakher doesn't work (tested on regex101.comExcite
Just catching up on some old comments - my regex was broken, thanks @Excite /^[a-zA-Z][\w\-.]{1,13}[a-zA-Z0-9]$/ I missed escaping the hyphen. Zakher if you happen to see this - the reason I used {1,13} is because you need to include the first and last characters which are defined separately in the regex. Sam - \w only matches characters [a-zA-Z0-9_] so would not match an emoji. Also changed final \w to not include underscore on final characterAustrasia
S
1

A regex to match the rules given in the other answer (if a positive lookahead is supported)

^(?=\S{3,15}$)[a-zA-Z][a-zA-Z0-9]*(?:[_.-][a-zA-Z0-9]+)?$

Explanation

  • ^ Start of string
  • (?=\S{3,15}$) Positive lookahead, assert 3-15 non whitespace chars to the end of the string.
  • [a-zA-Z] Match a single char a-z or A-Z
  • [a-zA-Z0-9]* Optionally repeat matching a-z A-Z or a digit 0-9
  • (?: Non capture group to match as a whole part
    • [_.-] Match one of _ . or -
    • [a-zA-Z0-9]+ Match 1+ occurrences of a-z A-Z or a digit 0-9
  • )? Close the non capture group and make it optional
  • $ End of string

See a Regex demo.

Salim answered 2/9, 2022 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.