php - Regex not giving the results expected -


so, got html tables need extract values, did regular expression values wanted.

the html tables can in these 2 formats:

<td height="20" style="width:59px;height:20px;">1</td>             <td style="width:212px;">mendes, paulo [aa]</td>             <td style="width:99px;">39</td>             <td>8</td>             <td style="width:85px;">$10,000</td>         </tr><tr height="20"><td height="20" style="width:59px;height:20px;">2</td>             <td style="width:212px;">campos, miguel [ac]</td>             <td style="width:99px;">37</td>             <td>6</td>             <td style="width:85px;">$5,000</td> 

and other one

<td>1</td>             <td>mendes, paulo [aa]</td>             <td>39</td>             <td>8</td>             <td>$10,000</td>         </tr><tr height="20"><td>2</td>             <td>campos, miguel [ac]</td>             <td>37</td>             <td>6</td>             <td>$5,000</td> 

to example without style can values want regex:

<td>(\d+)<\/td>\n+\t*<td>([\w+, ]+) \[(\w{2})\]<\/td> 

its used in php, , been using https://regex101.com/ test regex first.

now values of table styles i'm getting no luck.

tried "perfect match" with:

 <td height\=\"20\" style\=\"width\:59px\;height\:20px\;\">(\d+)<\/td>\n+\t*<td style\=\"width\:212px\;\">([\w+, ]+) \[(\w{2})\]<\/td> 

but doesn't catch want want. tried negation search still doesn't work. i'm doing wrong?

why don't use queryselectorall (''); lot easier. can used retrieve inner text of td elements , store them in array using loop. once have td can use jquery ajax send .php file process want.

for example:

var tdarr = [];  var tdcontent = document.queryselectorall('table tr td');  ( let = 0;  < tdcontent.length; i++){     tdarr.push(tdcontent[i].textcontent); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -