ID:2179214
 
(See the best response by Kaiochao.)
Code:
var/tmpName="WhatEveryOu want"
var/regex/R = new/regex("(^\[^A-Z]{1})(\[^A-Za-z\\s]{0,})(\[^a-zA-Z]$)")
if(R.Find(tmpName))


Problem description:

I have spent a good few hours trying to crack the regex code, and have only found the way in which I want the string to result, but simply cannot figure out how to detect if any of these following rules are NOT met.

1.) The first letter MUST begin with a capital.
2.) The string may not contain any text besides A-Za-z or a space.
3.) The string must not end with a space.

I am using this for name validation, as such.. All of the highlighted names in the above screenshot are to be considered valid. If any of the conditions are not met, it should (in theory) return the position in which it was found to be conflicting, which would throw a return value back.

Yet, if all conditions are met, it should not return anything at all.

tl;dr:
Regex confuses the hell out of me, what would be the best way for verifying the above rules with a simple if statement?
Best response
Seems you just have to use the negative look-ahead:
regex("^(?!\[A-Z]{1}\[A-Za-z\\ ]*\[a-zA-Z]$).*$", "gm")

http://stackoverflow.com/a/2637899
In response to Kaiochao
Thank you for the help, and the source explaining it!
{0,} can be replaced with * as the modifier (which Kaiochao did), and {1} is entirely redundant.

But I'm not sure why you want to match for the opposite, rather than simply matching the regex and saying it's incorrect if there's no match--unless your goal is to find the first character that's incorrect. If that's the case, it's easier to break this up into chunks anyway.

// Autocorrection is usually better for certain things, like changing an initial
// lowercase letter to uppercase, or trimming spaces.
proc/AutoCorrectName(name)
// trim
name = replacetext(name, new/regex("^[\\s\\n\\r]+", "gs"), "")
name = replacetext(name, new/regex("[\\s\\n\\r]+$", "gs"), "")

// replace consecutive spaces with just one
name = replacetext(name, new/regex("[\\s\\n\\r]{2,}$", "gs"), " ")

if(!name) return "" // blank; nothing else to correct

// autocap
var/ch = text2ascii(name, 1)
if(ch >= 97 && ch <= 122)
name = uppertext(copytext(name,1,2)) + copytext(name,2)
return name

// Returns a string if name is invalid
proc/ValidateName(name)
if(!name)
return "Name cannot be blank"

// Check initial caps
if(t < 65 || t > 90)
return "Name must begin with a capital letter"

// Check for unwanted characters
var/i = findtext(name, new/regex("[^A-Z\\s]", "is"))
if(i)
return "Character [copytext(name,i,i+1)] is not allowed"

Regular expressions let you offer a little more flexibility, too, so for instance you could allow ' or - and simply require a letter to either side. You could also allow for numbers.
In response to Lummox JR
Thanks for the different perspective on it! The reason I resorted to regular expressions was to keep checks minimal, though I do see how it could be used in that case.
I don't think keeping checks minimal is in your best interest if you want to tell people why certain names work and certain ones don't. If it's simply pass-fail without an explanation, then a single regex will do the trick just fine.