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-----
[Back to original message]
|