I'm probably doing things wrong but when I have a bit of functionality that needs to be reused I tend to make a function even if all the functions inside are core elements.
In fact you're right. Executing all of those horribly long and complicated statements saved you... 0.00145 seconds (rounded) of execution time across 5000 records, according to my tests. (PS: If you're regexing more than that at a single time, you're probably doing something wrong.)
You seem fixated on execution time. You really ran a bench mark?
I am surprised that you consider "preg_match'/^([A-Z]+\s[A-Z]+|[a-z]+\s[a-z]+)$/',$name)" to be long and complicated. Maybe I'm just smarter than most developers but to me it seems pretty basic.
I think that my statement is simpler to read than a -lot- of regex out there. Again, when you get beyond the 0.5 difficulty, this will become more clear to you. Just a question of application.
You seem to be saying that "if($str == strtoupper($str) || $str == strtolower($str))" can be used in place of all complicated expressions? I'm not so sure about that. I would think that more complicated expressions would probably require more complicated functions. In which case I don't really understand your point. Are you saying that if I use simple expressions then I will also be forced to use more complicated ones? Is this something the interpreter enforces?
I think I see part of my problem. I use expressions for things other than validation. Is that wrong? Expressions shall only be used for validation? If so then I fear I need to redo quite a bit of my sql code.
Which... is a custom function. So... I dont get your point here, except that you're proving my statement true.
For me at least it makes sense to use simple expressions for simple tasks. Truly validating an email is not a simple task. Therefore, I don't use expressions for email. Which is why your demand that I create one is very puzzling. I'm sure that my methodology will change once I gather sufficient experience but for the moment anyways, I try to use the best tool for the job at hand.