You are here: Re: Is there any function in php that will match a word exactly and if it finds it, it returns true. « PHP Programming Language « IT news, forums, messages
Re: Is there any function in php that will match a word exactly and if it finds it, it returns true.

Posted by The Natural Philosopher on 11/11/07 00:45

Brendan Gillatt wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> ross.oneill@gmail.com wrote:
>> Thanks for your response. But if in your example
>> strVar "Bob is from Canada" -- would return true when I want it to
>> return false.
>>
> *borrowing Krustov's code as template*
>
> $demo="Bob is from Los Angeles CA";
>
> $qaz=" CA"; // note the extra space
>
> $wsx=strpos($qaz,$demo);
>
> if ($wsx==true) {print "exact match found";}
>

How about "CAnada".

Faced with this sort of thing in 'C' I decided that learning to write a
regexp when I could already write C was bollocks:

You have to decide what is allowable before and after the 'CA" that
makes it a complete word, not part of something else.

In C the ispunct(), isspace() and '\0' macros proved useful.

>
> - --
> Brendan Gillatt
> brendan {at} brendangillatt {dot} co {dot} uk
> http://www.brendangillatt.co.uk
> PGP Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xBACD7433
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (MingW32)
>
> iD8DBQFHNjP4kA9dCbrNdDMRAnQ9AJ0dL6C23gPRQ4n40hjqIXg+H5nEQwCg0Yum
> r9nv+WwcsnZfQIC22bQCdlU=
> =uQxP
> -----END PGP SIGNATURE-----

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация