poking around near the end of a string

Devin Asay devin_asay at byu.edu
Wed May 10 11:07:36 EDT 2017


And don’t forget ‘begins with’. They were both added in v. 2.9.

Devin


On May 10, 2017, at 8:47 AM, Mike Bonner via use-livecode <use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>> wrote:

Ends with.. How did I not know about that?

On Wed, May 10, 2017 at 8:46 AM, Mike Bonner <bonnmike at gmail.com<mailto:bonnmike at gmail.com>> wrote:

if char -2 to -1 of MNOSE = "$W" should work.

LAST doesn't return a numeric value (as far as I can tell) so you can't
subtract from it, if you do you get strange results

In addition, the order matters.  You're putting the last char first, and
the second to last char last (if you were allowed to use last that way)  So
if it did work, you'd be checking W$ against $W

You could do it other ways too of course.  You could use (char
length(MNOSE) -1 of MNOSE & char length(MNOSE) of mNose)  to do the
comparison..  Note the -1 is first to keep the characters in order.




On Wed, May 10, 2017 at 8:18 AM, Richmond via use-livecode <
use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>> wrote:

Suppose I have a string a bit like this:

"and then the gigantic monster bit my mother on the nose $W"

and I want to check that that string ends with "$W" . . .

I tried this (pseudo code):

*if the ((last char) & (last char -1)) of MNOSE = "$W"*

and it did not work.


Richmond.

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University



More information about the Use-livecode mailing list