css - 如何使用 AppleScript 获取类的计数?

标签 css html count applescript bbedit

Learning AppleScript 我正在尝试练习,我想看看我是否可以在 .xhtml 中获得一个类的计数。文件。

在我的 BBEdit 元素中,我为元素设置了一个变量:

set this_project to file of project document 1

确保以所有 .xhtml 为目标文件:

set total_xhtml to {search mode:grep, case sensitive:false, match words:false, extend selection:false, returning results:true, filter:{ID:"111232452", filter_mode:and_mode, filter_terms:{{operand:"xhtml", field:«constant ****FnSf», operator:op_is_equal}}}}

但是当我尝试计算每个文件的类别时,我感到很困惑..

我试过:

set varCount to count class=\"foobar\"" of (this_project in total_xhtml)

如果我尝试 set varCount to count class=\"foobar\""它在 AppleScript 编辑器中返回一个数字,但我如何才能获得元素中每个文件的完整计数?

最佳答案

如果我理解你的问题,你想知道你的类在不同的 .xhtml 文件中列出了多少次。

如果这就是您想要完成的,下面是一个工作示例,它应该可以满足您的要求。

on run
     try
         set foundItems to do shell script "grep -ri 'yourClassName' " & quoted form of "/Path/to/Your/directory"
     on error
         set foundItems to ""
     end try

     set oldDelims to AppleScript's text item delimiters -- save their current state
     set AppleScript's text item delimiters to {return} -- declare new delimiters
     set tempList to every text item of foundItems
     set AppleScript's text item delimiters to oldDelims -- restore them

     set foundCount to count of tempList
end run

关于css - 如何使用 AppleScript 获取类的计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24615729/

相关文章:

css - 在 less 中复制 CSS 规则

javascript - 使用 HTML/CSS/JS 将图像放置在文本字段中?

javascript - 在下拉框中选择项目时如何在文本框中获取属性值?

java - 如何统计数组列表中单词的重复次数?

mysql - 选择其他列也有重复项的 lead_id

css - 如何使 HTML5 输出使用逗号?

jquery - 删除父类的::before 样式

INSERT INTO 语句中的 PHP 语法错误。SQLExecDirect 中的 SQL 状态 37000

html - CSS Height 属性详解

mysql - 在一个表1中按月(Unix时间戳)计数并将结果写入表2