sublimetext2 - Sublime Regex extract -


<.*>|\n.*\s.*\sid="(\w*)".*\n+|.*>\n|\n.+  , replace $1 

this regex can take id out file

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

result maker

how can extract gettheresult key name?

so result local6

tried   <.*>|\n.*\s.*\sgettheresult('(\w*)').*\n+|.*>\n|\n.+ didn't helped 

i assume that:

  • you have files text gettheresult('local6')
  • you may have several values on line
  • you'd keep text only, 1 value per line.

i suggest

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

and replace $1\n. \n insert newline between values. can use ^\n regex (to replace empty string) remove empty lines.

pattern details:

  • gettheresult\(' - matches gettheresult(' literal string (note ( escaped)
  • ([^']*) - group 1 capturing 0+ chars other '
  • '\) - literal ')
  • | - or
  • (?:(?!gettheresult\(')[\s\s])* - 0+ chars not starting chars of gettheresult(' character sequence (this tempered greedy token).

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -