Re: Inconsistent behavior with preg_match_all in conditional
| From: | Randy Janinda | Date: | Wed, 29 May 2002 15:26:20 +0000 |
| Subject: | Re: Inconsistent behavior with preg_match_all in conditional | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99759@lists.php.net to get a copy of this message | ||
It never fails. I mention toil for hours and mention the problem to a
public forum and it turns out to be a typo. Thanks Jason.
On Wed, 2002-05-29 at 00:30, Jason Wong wrote:
> On Wednesday 29 May 2002 11:06, Randy Janinda wrote:
> > Hello everyone,
> >
> > I have a script to check a user submitted string. It may be multiple
> > words. If a word is found to be 3 characters or less, the script should
> > retain the case of the string IF all the characters are uppercase.
> > Otherwise, the script will make the first character of each word
> > uppercase. So "Main st" becomes "Main St" and "Main st NB"
> > becomes "Main
> > St NB". Easy enough right?
> >
> > So take a look and let me know if this is a bug or feature.
> >
> > Here's the chunk of code and you can test it in action at
> > http://www.tqlabs.com/testcase.php (and .phps
> > accordingly):
> >
> > if ($MyString) {
> > $safeInfo = explode(" ",strip_tags(stripslashes(trim($MyString))));
> > foreach($safeInfo as $strTok) {
> > print "Checking: $strTok<BR>";
> > if (strlen($strTok) <= 3) {
> > $case = preg_match_all("/[A-Z]/",$strTok,$junk);
> > $count = strlen($strTok);
> >
> > ///////////////////////////////////////
> > // Why won't this work?!?!?!
> > ///////////////////////////////////////
> > if (preg_match_all("[A-Z]",$strTok,$junk) == strlen($strTok)) {
>
> Is this a typo? Shouldn't it be the same as above with the '/' delimiters?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>