メインコンテンツまでスキップ
バージョン:25.2

instance, instances

  • keyword (synonym for occurrence)

  • replace/delete first/last n instances

  • replace/delete ordinal instance

  • replace/delete instance n

  • replace/delete all/every instance

  • the number of instances of

  • Synonyms: occurrence, occurrences

  • function — instance, every instance (of text or pattern)

  • new in 1.81

  • chunk type

  • new in 1.81

  •     The match chunk type will return a pattern match property list:

         put the second match of <3 digits> in "987654321"
-> (text:"654", text_range:"4" to "6")

    Unlike other text chunk types, requesting a range of matches or occurrences will return a list of values rather than a substring of the string:

         put instances 3 to 5 of <digit> in "V2.7 for 4/3/18"
-> (4,3,1)
put the first 3 occurrences of <max digits> in "42-16gh9-88"
—> (42,16,9)
put the last 2 matches of <max digits> in "42-16gh9-88"
—> ((text:"9", text_range:"8" to "8"),(text:"88", text_range:"10" to "11"))

    When used as a container (to put something before, into, or after the chunk), occurrence and match chunks behave like other types of chunks, identifying a range of characters in the string.

         set text to "[a]hello[b]bonjour[c]hola[d]"
set marker to <"[", character, "]">
put occurrences 2 to 3 of marker in text
—> ("[b]","[c]")
put "$$$" into occurrences 2 to 3 of marker in text
put text
—> "[a]hello$$$hola[d]"