将正则表达式结果保存到变量

时间:2018-08-19 02:52:10

标签: regex applescript

我在带有Satimage osax的applescript中使用正则表达式。一切正常,但我希望能够将返回的匹配项保存到变量以使用

这是我在applescript编辑器的“答复”部分中看到的:

find text "(?i)(nhl|nfl|ncaa)" in "NFL games.pdf" with regexp
    --> {matchPos:0, matchLen:3, matchResult:"NFL"}

我能够使用对话框显示结果,但是无论尝试如何,都无法将其保存到变量中。

作品:

display dialog matchResult of (find text "(?i)(nhl|nfl|ncaa)" in theName with 
regexp)

不起作用:

set matchResult of (find text "(?i)(nhl|nfl|ncaa)" in theName with regexp) to 
keywordResult
set (matchResult of (find text "(?i)(nhl|nfl|ncaa)" in theName with regexp)) to 
keywordResult

任何帮助将不胜感激!

瑞安

1 个答案:

答案 0 :(得分:0)

<div class="suggestedvids">
  <div class="onevid">
    <img class="thumbnail" src="https://i.ytimg.com/vi/NO2DaxhoWHk/mqdefault.jpg" />
    <a class="vidInfo">
      <p>Build Real Web App with React #01</p>
      <br><br>
      <p>Rem Zolotykh</p>
    </a>
  </div>
</div>

gdp_df.iloc[i, 3] = 1

您还可以:

set keywordResult to matchResult of (find text "(?i)(nhl|nfl|ncaa)" in theName with regexp)