0

I'm using powerGrep to find instances of these:

BLOCK 1:

<td class="danish">kat
<?php audioButton("../../audio/words/dog","dog");?></td>

But there are also instances of these among my files:

BLOCK 2

<td class="danish">kat</td>
<td><?php audioButton("../../audio/words/dog","dog");?></td>

I want to find BLOCK 1 only, not BLOCK 2.

I've tried using (?!), as in

.*<td class(.*?)>(.*)(?!</td>)
.*<\?php audioButton\("(.*)/.*",".*"\);.*\?></td> 

Can I somehow exclude the </td> tag from the search, so that BLOCK 2 is ignored?

Moogal
  • 107
  • 1
  • 9

1 Answers1

1

I am not sure why you really want to match the first cell tag only, but to perform this you can try:

<td[^>]*>\s*(?:.(?!</td>))+\s*<\?php audioButton\("[^"]*/(.+?)","(.*?)"\);.*?\?>.*?</td> with g flag.

see it working here: https://regex101.com/r/tI4rL4/1

[EDIT]

You can also see the replacement of dog to cat here: https://regex101.com/r/tI4rL4/2

It may not be perfect, since the question is a bit too vague, but it works. If you need to refine a bit or adjust or need a bit of explanation you can ask me!

antoni
  • 5,001
  • 1
  • 35
  • 44
  • Hi Antoni. Thanks a lot for helping :) I guess my question could have been clearer. I've edited it now, so hopefully it's more understandable. I don't want it to match any instances of Block 2. – Moogal Sep 13 '16 at 07:10
  • Yes it is what I first understood, so if you go to the link of my demo it does match only block 1 `dog` instances and not block 2 `dog` instances. Isn't it what you want? :) – antoni Sep 13 '16 at 07:32
  • Yes! That's what I want! Thank you very much :) – Moogal Sep 13 '16 at 07:38