Is my name official?
Retina, 13 bytes
^[A-Z][a-z]+$
Try it online | Test suite (The output 0
means none of the strings matched, which is expected.)
When Retina is only provided with a single line of code, it outputs the number of times the expression matched the input string, so it will output 1
(truthy) if it matches and therefore is an official name and 0
(falsy) if it's not.
Breakdown
^ The beginning of the string
[A-Z] One uppercase letter
[a-z]+ One or more lowercase letters
$ The end of the string
TeaScript, 12 bytes
xO`A-Z][a-z`
Abuses the O
function.
Try this online
Test Suite
Explanation
The O
function makes this:
x O `A-Z][a-z`
x.O(/^[A-Z][a-z]+$/)
Then, the O function checks if the regex matches x
.
Alternatively, a non-competing TeaScript 3 answer at 7 bytes:
xO/\A\a
JavaScript (ES6), 26
n=>/^[A-Z][a-z]+$/.test(n)
By: Edcsixtyfive
f=n=>/^[A-Z][a-z]+$/.test(n)
console.log=x=>O.textContent+=x+'\n'
;['Adnan','adnan','AdnaN','Adnan123','Adnan Adnan','A','Mary-Ann']
.forEach(t=>console.log(t+' '+f(t)))
<pre id=O></pre>