• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Text comparison no working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Text comparison no working


  • Subject: Text comparison no working
  • From: Jim Brandt via AppleScript-Users <email@hidden>
  • Date: Fri, 17 Sep 2021 16:06:01 -0500

I've got a peice of code that I've pulled from a handler that ins't working the
way I expected it to.

Here's the code:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set IntroNames to {"Forward", "Foreward", "Prologue", "Introduction"}

set LinkText to "<span class=\"link\"><a
href=\"Mybook/chapters/linktoforward\">Foreword</a></span>"
set NameStr to "(<span class=\"link\".*?\">)(.*?)(</a></span>)"
set LinkName to change NameStr into "\\2" in LinkText with regexp

--set LinkName to "Foreward"

set TheClass to class of LinkName
set NameLength to length of LinkName
set AddSpace to IntroNames contains LinkName


When I run this code, the variable "LinkName" contains the text "Foreward"

When the last line executes, the result is false, which is NOT what I expected.

When I uncomment --set LinkName to "Foreward” line, and run the code, the
result of the last line is true, which is what I expected it to be.

I added the class and length lines just to verify that the variable LinkName
was coming out as expected, a text variable of length 8 characters.

BTW, the "change" command is part of the Satimage OSAX which I use quite a bit.

Anybody have a clue as to what I'm not doing correctly here?


Jim Brandt

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Text comparison no working
      • From: Christopher Stone via AppleScript-Users <email@hidden>
    • Re: Text comparison no working
      • From: Axel Lüttgens via AppleScript-Users <email@hidden>
  • Next by Date: Compress contents of folder using parent folder as zip name
  • Next by thread: Re: Text comparison no working
  • Index(es):
    • Date
    • Thread