0

I want to extract values from the code below.

<tbody>
    <tr>
      <td><div class="file_pdf"><a href="javascript:downloadFile('1628')">note1</a></div></td>
      <td class="textright">110 KB</td>
      <td class="textright">106</td>
    </tr>
    <tr>
      <td><div class="file_pdf"><a href="javascript:downloadFile('1629')">note2.pdf</a></div></td>
      <td class="textright">44 KB</td>
      <td class="textright">104</td>
    </tr>
  </tbody>

I want to extract 'note1', 'note2' strings and 1628 and 1629 numbers.

i treid

preg_match_all('~(\'\)\">(.*?)<\/a>)~', $getinside, $matches);

but its result is not what I am looking for..

is there any simple RegEx to extract them? Thanks!

1 Answer 1

1

It should work for you:

preg_match_all("~downloadFile\('(\d+)'\)\">([^<]*)</a>~", $getinside, $matches);

Remember: If your html is very large/complex and you also need to parse more other things from there, then regex is not a better option to do this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.