如何用正則表示式獲得頁面中的指定資料?
<tr>
<td align='center' class='orang'>07098</td>
<td width='35' align='center' class='yellow'>3</td>
<td width='26' align='center' class='yellow'>7</td>
</tr>
於是我寫了這個程式,用來提取以<tr>開頭,</tr>結尾的內容
String regEx=".+(<tr>.+</tr>).+";
Pattern p=Pattern.compile(regEx,Pattern.DOTALL);
Matcher m=p.matcher(string); //string為頁面的HTML程式碼
while(m.find())
{
System.out.println(m.group(1));
}
但每次都只能得到表格的最後一行,這是為什麼啊?
相關推薦
如何用正則表示式獲得頁面中的指定資料?
我想得到一個table裡的每一行資料,格式如下: <tr> <td align='center' class='orang'>07098</td> <td width='35' align='center' class='yellow'>3<
用正則表示式提取img中src資料
分享了正則表示式提取img的src的方法,一起來了解下。 要匹配的字串:<img src=image/ad1.gif width="128" height="36"/><img src='image/ad2.gif' width="128" height=
QT 用正則表示式從tableView中篩選出某一日期範圍內的資料
QDate date1,date2; date1=ui->dateEdit_2->date();//提取開始時間 date2=ui->dateEdit_3->date();//提取結束時間 data_filter->
根據正則表示式匹配頁面中js和css檔案
// 匹配 List<string> srcList = new List<string>(); List<string> linkList = new List<string>();
用正則表示式得到Java中所有的關鍵字
在一個Java應用程式中,我們可以用正則表示式可以得到所有的java關鍵字。那麼關鍵就是正確地使用詞邊界。例如:在"static staticField"這個字串當中,第一個單詞應該被當作關鍵字識別,但是第二個不能。這
用正則表示式去掉C++中的註釋內容
C++中的註釋內容,有兩種樣式: // 和 /* */ 針對這兩種樣式,正則表示式可以為\/\*[\s\S]*\*\/|\/\/.* \/\*[\s\S]*\*\/可以識別/* */整塊註釋, \
用正則表示式獲取URL中的查詢引數
總結獲取url中查詢引數的兩種方式 通過正則表示式獲取單個引數 url中的所有查詢引數可以通過 window.location.search 欄位獲取,以字串的形式返回。並有固定的格式 ?param1=value1¶m2=value2···,所以可以正則表示式匹配。 分析下需要匹配的格式:
實現了用正則表示式批量替換更新資料庫資料
select regexp_replace('e:/fs_root/images/host_21_wangyiblog/2009/11/30/14/00/2009113014000560.jpg','e:/fs_root/(.*?)/[^/.]*?.jpg','//1
請實現一個函式用來匹配包括'.'和'*'的正則表示式。模式中的字元'.'表示任意一個字元,而'*'表示它前面的字元可以出現任意次(包含0次)。 在本題中,匹配是指字串的所有字元匹配整個模式。
題目描述 請實現一個函式用來匹配包括'.'和'*'的正則表示式。模式中的字元'.'表示任意一個字元,而'*'表示它前面的字元可以出現任意次(包含0次)。 在本題中,匹配是指字串的所有字元匹配整個模式。例如,字串"aaa"與模式"a.a"和"ab*ac*a"匹配,但是與"aa.a"和"ab*a"均
PHP用正則批量替換Img中src內容,用正則表示式獲取圖片路徑實現縮圖功能
/** * 圖片地址替換成壓縮URL * @param string $content 內容 * @param string $suffix 字尾 */ function get_img_thumb_url($content="",$suffix="!c550x260.jpg") { // by
請實現一個函式用來匹配包括'.'和'*'的正則表示式。模式中的字元'.'表示任意一個字元,而'*'表示它前面的字元可以出現任意次(包含0次)。 在本題中,匹配是指字串的所有字元匹配整個模式。例如,字
public class Solution { public boolean match(char[] str, char[] pattern) { if(str==null||pattern==null) { return
Python 用正則表示式一次替換文章中所有特殊符號,如“-,$()#+&*”之類
一個簡單的正則表示式,可能會起大作用。比如說字符集就是這樣。一篇文章如果有各種亂碼,就可以用這種方法去除。如去除“-,$()#+&*”之類符號是很方便的。按照查詢、分割、替換的套路再做一做這樣的練習。今天晚了,後續還要操作檔案來完善這一點。 import re
請實現一個函式用來匹配包括'.'和'*'的正則表示式。模式中的字元'.'表示任意一個字元,而'*'表示它前面的字元可以出現任意次(包含0次)。 在本題中,匹配是指字串的所有字元匹配整個模式。例如,字
本題源自劍指offer ----------------------------------------------------------------------------------- 如果模式串遇到*字元則有兩種狀態,第一匹配字元,則字串後移一位,模式串不變,第二,
巧用正則表示式載入靜態頁面(HTML5+Jquery)
很多人可能用過Vie.js,網頁動態載入資料。一般來說,HTML在後面呼叫new Vue()載入資料的。Vue很有創意,在HTML中插入{{}}標記,使用HTML模板化,方便開發。但其也有一定不便。我受Vue啟發,想與Jquery結合(我很喜歡JQuery)。 我嘗試使用$Ajax()載入資料,並把資料顯示
在QTavleView中新增QLineEdit(用正則表示式校驗輸入的IP地址)
在QTableView中新增QLineEdit,並且該QLineEdit是需要填入IP地址,因此輸入的資料必須遵循IP地址的規則。這時可以使用QT中的委託。 委託的一篇文章http://blog.csdn.net/hello_world_lvlcoder/article
【python學習筆記】用正則表示式從含中文的網頁中提取資料(含編碼轉換)
目標:用正則表示式從含中文的網頁中提取資料 1、獲得網頁全部資料 1.1思考過程 確定我們要操作的網頁:url = 'http://q.stock.sohu.com/cn/603077/cwzb.shtml' 開啟要操作的網頁:req = urllib2.open(url)
3.7 python 中 用正則表示式 郵箱及電話號碼的匹配
import re c = re.compile(r'^\[email protected](\w+\.)+(com|cn|net|edu)$') # string = ' [email protected]' string = '[email protected]'
用正則表示式切割詳細地址中的省、市、區(例如:address=陝西省延安市寶塔區寶塔山街道寶塔山景區,切割之後為province=陝西省, city=延安市, county=寶塔區寶塔山街道寶塔山景)
將詳細地址切割為省市區工具類(還要切割到鎮、村莊參考博文:https://blog.csdn.net/superSubfn/article/details/80290491) package com.camelot.attendance.util; import java.util.Arr
用正則表示式從攜程頁面原始碼提取酒店資訊並插入mysql資料庫
file_regEx_mysql_io desc: 從txt檔案中讀取字串,通過正則表示式提取關鍵字,並插入mysql資料庫的一個小demo. 前言 因為最近公司需要用到攜程上面的一些酒店資料,由於沒有接觸過爬蟲,所以只能投機取巧去爬html原始檔的程式碼,然後
Mssql中實現用正則表示式更新欄位值
create function dbo.regexReplace ( @source varchar(5000), --原字串 @regexp varchar(1000), --正則表示式 @replace varch