Difficulty to get information through Regular Expressions

Asked

Viewed 29 times

1

I’m having trouble getting information using preg_match_all.

This information is being taken from an HTML code of an intranet page, but from the information I need, I am managing to collect only one.

Follow a piece of code where the information is:

        <img src="../../../img/prioridade_normal.png" style="vertical-align:middle;" width="20" height="20" align="top" border="0" title="Solicitação: Mudança de sala dentro da Gerência.&#13;Atribuição: Ponto de rede em cabeamento estruturado/Ativação/Instalação/">

                      </td>
                      <td width="20">

                            <img src="../../../img/alocacao_outro_profissional.png" style="vertical-align:middle;" width="20" height="20" align="top" border="0" title="Alocado para Tecnico 1" >

                      </td>
                      <th  scope="col" class="textoAtendimentoBranco" style="vertical-align:middle;">
                      <strong>19445/2015</strong>:2
                      </th>

The information I need is between the tags <title>, in which I am able to capture. What I am not getting is to collect the information that is between <STRONG> </STRONG>.

The code I’m using to retrieve this information:

 preg_match_all("/title=\"(.*)/", $url, $conteudo);

My difficulty lies in how to also recover what is between <STRONG> in the same Regular expression being used for the <title>.

1 answer

1


Hit on to :

preg_match_all("/title=\"(.*)\"|<strong>(.*)</strong>/", $url, $conteudo);
  • You’ve been tempted this way, but it never works. To use this way I have to insert a "break" in the </Strong> tag thus: preg_match_all("/title="(.)|<Strong>(.)</Strong>/", $url, $content); , but it does not contain the desired content.

  • but what is it bringing to you? What is the desired content? In the regex Tester it worked, strange, what is the return problem ae?

  • does not bring me what is between the tags of <STROONG>, which using the above code, should be 19445/2015

  • I was able to make the necessary adjustment and is now returning the desired value, but also bringing other information that are also among the <STRONG> tags. You have to restrict the return of numeric value. I only care what it contains number. What you should add in the ER for that?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.