Q:

How do you write regular expressions for a valid username for swift? 

Here are some requirements for being a valid username:

No special characteristics
Allow underscore
No spaces
Letter and numbers between 1-13 characters

A:

^\w{1,13}$

^ beginning of string anchor
\w word character - any letter (including UTF-8), any case, 0-9 and underscore
{1,13} length between 1 and 13, inclusive
$ end of string anchor
https://regex101.com/ - good resource

