0

I have this kind of rows.

<li><a href="love-and-attitude.html" title="Love and Attitude">Love and Attitude (24)</a></li>
<li><a href="paint-and-gain.html" title="Paint And Gain">Paint And Gain (15)</a></li>
<li><a href="mother-and-father.html" title="Mother And Father">Mother And Father (19)</a></li>

I want to select with regex only the text between title tag and close tag. So, after using regex, I should have. The desire output:

Love and Attitude (24)

Paint And Gain (15)

Mother And Father (19)

2

1 Answer 1

1

Caution: this will not work if you have > in any attribute of <a> tag or < in the text you want to extract. In that case you have to use a parser instead.

  • Ctrl+H
  • Find what: ^\h*<li><a[^>]+>([^<]+).+$
  • Replace with: $1
  • UNcheck Match case
  • check Wrap around
  • check Regular expression
  • DO NOT CHECK . matches newline
  • Replace all

Explanation:

^           # beginning of line
  \h*       # 0 or more horizontal spaces
  <li><a    # literally
  [^>]+     # 1 or more any character that is not >
  >         # literally >
  (         # start group 1
    [^<]+   # 1 or more any character that is not <
  )         # end group 1
  .+        # 1 or more any character
$           # end of line

Replacement:

$1          : content of group 1 (i.e. the text you want)

Result for given example:

Love and Attitude (24)
Paint And Gain (15)
Mother And Father (19)
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .