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

and replace $1

This regex can take all id out from file

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

Result is maker

How can I extract getTheResult key name?

so my result will be local6

Tried   <.*>|\n.*\s.*\sgetTheResult('(\w*)').*\n+|.*>\n|\n.+ but didn't helped
Kunal Vashist
  • 2,110
  • 6
  • 24
  • 55

1 Answers1

1

I assume that:

  • you have files with text like getTheResult('local6')
  • you may have several values like that on a line
  • you'd like to keep those text only, one value per line.

I suggest

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

and replace with $1\n. The \n will insert a newline between the values. You can then use ^\n regex (to replace with empty string) to remove empty lines.

Pattern details:

  • getTheResult\(' - matches getTheResult(' as a literal string (note the ( is escaped)
  • ([^']*) - Group 1 capturing 0+ chars other than '
  • '\) - a literal ')
  • | - or
  • (?:(?!getTheResult\(')[\s\S])* - 0+ chars that are not starting chars of the getTheResult(' character sequence (this is a tempered greedy token).
Community
  • 1
  • 1
Wiktor Stribiżew
  • 484,719
  • 26
  • 302
  • 397