-1

I have this expression

<h3 id="productPageRightSectionTop-authors-h3">de <a id="productPageRightSectionTop-author-lnk" data-id="2316">José Saramago</a>; Ilustração:  <a id="productPageRightSectionTop-entidade-lnk">João Caetano</a>&nbsp;</h3>

i made this one

<h3 id="productPageRightSectionTop-authors-h3">de <a id="productPageRightSectionTop-author-lnk" data-id="[0-9]+">(.+)</a>

but is getting everything and i just want this part

<a id="productPageRightSectionTop-author-lnk" data-id="2316">José Saramago</a>

Do you have any idea how i can do that?

Wiktor Stribiżew
  • 561,645
  • 34
  • 376
  • 476

1 Answers1

0

The problem is at the end of the regex:

data-id="[0-9]+">(.+)</a>

(.+) is too greedy and match everything afterwards. Changing that part to:

data-id="[0-9]+">[^<]*</a>

should fix the selection. The selector should look like:

<h3 id="productPageRightSectionTop-authors-h3">de <a id="productPageRightSectionTop-author-lnk" data-id="[0-9]+">[^<]*</a>

ntotomanov
  • 76
  • 1
  • 3
  • Thank you, it solved the problem. and its working amazingly. Perhaps do you know how to search end in the middle of the expression we have for example %2F%? – user6236820 May 15 '16 at 11:01
  • now i have this `src="https://images.portoeditora.pt/getresourcesservlet/image?EBbDj3QnkSUjgBOkfaUbsI8xBp%2F033q5Xpv56y8baM5A05y80e0FC%2FSoPzrzcwjT&width=250"` and i have to save the link...how would you do it? i think that its because of the % that i can't do it cause i have other expressions exactly like that. – user6236820 May 15 '16 at 11:04
  • To match the link in the scr you can use: src="[^"]+" or if you want to put it in variable: src="([^"]+)" – ntotomanov May 15 '16 at 12:30