If ever you can script without using PCRE (Perl Compatible Regular Expressions) you should do so since PCRE uses a lot of processor resources. As I recall, Perl has an engine specifically designed for regex and is not processor heavy.
Printable View
If ever you can script without using PCRE (Perl Compatible Regular Expressions) you should do so since PCRE uses a lot of processor resources. As I recall, Perl has an engine specifically designed for regex and is not processor heavy.
It is done with this one... can someone take a look to this?? HERE
Ah, and I think I was reading yours wrong.
Does the function check for ANY matches or a complete match from the whole string?
You're saying "exists [uppercase] and exists [lowercase]", not "[whole string is upper] and [whole string is lower]".
I read it the second way when I first saw your post.
In other words, preg_match returns TRUE upon finding a match, rather than returning FALSE upon finding a non-match.
Yes, that would work, but personally I'd prefer the more "human readable" string functions (when they work, of course-- sometimes regex is needed/easier).
Exactly.[A-Z]is the character range we're searching for, and+means "one or more of".
Using functions might be quicker, since regex can be more process-intensive, but with the (likely small) size of our $string, I don't think it would be an issue. I think it would improve the speed of the regex if I combined them into a single pattern, too, instead of checking twice.
I'm not sure you would be able to combine them together in the sense that you are checking if (1) and if (2), not if (1/2).
My motivation for using string functions is simply that they are easier (for me). Regex likely is a bit slower, but using it can be more standardized if you are doing a lot of checks for lots of different patterns and it can also do a lot that string functions can't.
this works. true for UPPER and lowercase, but not UPPER or lowercase:PHP Code:preg_match('/(?=.*[A-Z])(?=.*[a-z])/', $str)