2017-10-09 78 views
0

我需要幫助。使用import.io並希望使用正則表達式來湊表中的數據,並希望從一些列獲得價值 我',這裏是代碼Import.io - REGEX從th得到表td值

<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

索裏做到這一點,我的意思是從38-43,我一直在編輯 –

回答

2

<tr>\s*<td>\s*\K\d+

<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) 
+0

謝謝回答,怎麼樣ü唱xpath?此HTML <表ID = 'T01'>大小斯托克 Pesanan最後更新​​36​​4​​0​​​​37​​6​​0​​09 Oct 17,16:20:34​​38​​5​​0​​17年10月8日,15時41分15秒​​39​​6​​0​​​​40​​7​​0​​17年10月4日,17:27:02 –