崇高的正则表达式提取物

Sublime Regex extract

<.*>|\n.*\s.*\sid="(\w*)".*\n+|.*>\n|\n.+

and replace 

这个正则表达式可以从文件中取出所有 id

<a href="java" class="total" id="maker" placeholder="getTheResult('local6')">master6<a>

Result is maker

如何提取 getTheResult 键名?

so my result will be local6

Tried   <.*>|\n.*\s.*\sgetTheResult('(\w*)').*\n+|.*>\n|\n.+ but didn't helped

我假设:

  • 您的文件包含 getTheResult('local6')
  • 等文本
  • 您可能在一行中有多个类似的值
  • 您只想保留这些文本,每行一个值。

我建议

getTheResult\('([^']*)'\)|(?:(?!getTheResult\(')[\s\S])*

并替换为 \n\n 将在值之间插入换行符。然后,您可以使用 ^\n 正则表达式(用空字符串替换)删除空行。

图案详情:

  • getTheResult\(' - 匹配 getTheResult(' 作为文字字符串(注意 ( 被转义)
  • ([^']*) - 第 1 组捕获 '
  • 以外的 0+ 个字符
  • '\) - 文字 ')
  • | - 或
  • (?:(?!getTheResult\(')[\s\S])* - 0+ 个字符不是 getTheResult(' 字符序列的起始字符(这是 )。