我需要帮助。 我正在使用import.io并希望使用正则表达式来获取表数据,并希望从某些列中获取值,这里是代码
<table>
<tr>
<td class='label'>No. Urut</td>
<td class='titikdua'>:</td>
<td>201</td>
</tr>
<tr>
<td class='label'>Kode</td>
<td class='titikdua'>:</td>
<td>DF 045</td>
</tr>
<tr>
<td class='label'>Warna</td>
<td class='titikdua'>:</td>
<td>HITAM</td>
</tr>
<tr>
<td class='label'>Bahan</td>
<td class='titikdua'>:</td>
<td>KULIT</td>
</tr>
<tr>
<td class='label'>Berat</td>
<td class='titikdua'>:</td>
<td>0 gr</td>
</tr>
<tr>
<td class='label'>Info</td>
<td class='titikdua'>:</td>
<td>SOL : FIBER</td>
</tr>
</table>
</div>
<div id='fr-stok'>
<table id='t01'>
<tr>
<th>Size</th>
<th>Stok</th>
<th>Pesanan</th>
<th>Last Update</th>
</tr>
<tr>
<td>38</td>
<td>4</td>
<td>0</td>
<td></td>
</tr>
<tr>
<td>39</td>
<td>5</td>
<td>0</td>
<td>05 Oct 17, 15:39:53</td>
</tr>
<tr>
<td>40</td>
<td>11</td>
<td>0</td>
<td></td>
</tr>
<tr>
<td>41</td>
<td>4</td>
<td>0</td>
<td>08 Oct 17, 12:24:28</td>
</tr>
<tr>
<td>42</td>
<td>0</td>
<td>0</td>
<td>07 Oct 17, 14:22:07</td>
</tr>
<tr>
<td>43</td>
<td>6</td>
<td>0</td>
<td>04 Oct 17, 15:52:41</td>
</tr>
</table>
我希望获得大小值并将其转换为 38,39,40,41,42,43 我如何使用正则表达式
答案 0 :(得分:2)
<tr> matches the characters <tr> literally (case sensitive)
\s*
matches any whitespace character (equal to [\r\n\t\f\v ])
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
<td> matches the characters <td> literally (case sensitive)
\s*
matches any whitespace character (equal to [\r\n\t\f\v ])
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
\d+
matches a digit (equal to [0-9])
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)