view that across different databases?
Thanks
组),则可以成功截取。但若
内的内容无法截取。有谁知道怎么搞定这个问题吗?求给点意见
以下是Java的代码:
public static void main(String[] args) throws IOException {
File source_file = new File("./data/page source.txt");
FileReader fr = null;
BufferedReader br = null;
try {
fr = new FileReader(source_file);
br = new BufferedReader(fr);
} catch (FileNotFoundException e2) {
e2.printStackTrace();
}
String pageSource = null;
String regEx = "
.+?)
int i=0;
while ((pageSource = br.readLine()) != null) {
Pattern pat = Pattern.compile(regEx);
Matcher mat = pat.matcher(pageSource);
while(mat.find()) { // replace" "
i++;
System.out.println(i+" "+mat.group(1));
}
}
}
正则表达式为:String regEx = "
(.+?)
以下是匹配的HTML源代码的样例
I am really excited about taking this course, because as a student, I
have always been very excited about teachers who made a point to incorporate
media and technology in the classroom. For me, it has always made
learning a bit more fun. Particularly, in high school, I remember
taking physics (which I really didn't enjoy) but my teacher used a
SmartBoard and incorporated our cell phones into our lessons, and it always
made it that much more intriguing. I think it is important to learn
how to incorporate such technology into the classroom setting because it
will stimulate the students, even if they don't have a strong interest
in the particular subject.
At the same time, I hope that I am able
to keep up with classroom technology. As a young teacher-hopeful, I am
very aware of technology in today's society and learning about all of
the new available technologies. Yet, I know it is a very fast paced
market,and I hope to be able to keep learning as I continue into my career.&
#160;
这一块能截取
The game I remember was the Oregon Trail. Maybe this is because no other
game stuck in my head or because my classroom was so into it this game that
it stuck in my head.
The best part of this game was that everyone in my class was involved and
excited about the game. From the very extroverted to those who were not, it
allowed all of my classmates to have input and participate.
这一块不能截取
问题是出在正则表达式里么?求懂这一块的高手支招啊~~艾玛谢不尽啊
发帖数: 1005
【在 o********g 的大作中提到】
: 已读入html文件,现用正则表达式截取
: 组),则可以成功截取。但若
: 内的内容无法截取。有谁知道怎么搞定这个问题吗?求给点意见
: 以下是Java的代码:
: public static void main(String[] args) throws IOException {
: File source_file = new File("./data/page source.txt");
: FileReader fr = null;
: BufferedReader br = null;
: try {
: fr = new FileReader(source_file);
发帖数: 298
http://www.mitbbs.com/article_t/Java/31141889.html
【在 e*****t 的大作中提到】
: 不是regex高手,要是我,直接把html parse了,用xpath搞定。
发帖数: 14
发帖数: 883
Matcher m = p.matcher(input);
if (m.matches()) {
int cnt = m.groupCount();
System.out.println(cnt);
String g1 = m.group(1);
System.out.println(g1);
String g2 = m.group(2);
System.out.println(g2);
}
发帖数: 65
发帖数: 9224
不要写regex, 这个我做过很多时间了。你会发现,你写了,就算没问题,将来维护也
麻烦。得不偿失哈。
我的经验总结。
【在 o********g 的大作中提到】
: 已读入html文件,现用正则表达式截取
: 组),则可以成功截取。但若
: 内的内容无法截取。有谁知道怎么搞定这个问题吗?求给点意见
: 以下是Java的代码:
: public static void main(String[] args) throws IOException {
: File source_file = new File("./data/page source.txt");
: FileReader fr = null;
: BufferedReader br = null;
: try {
: fr = new FileReader(source_file);
http://www.mitbbs.com/article_t/Java/31141889.html
【在 e*****t 的大作中提到】
: 不是regex高手,要是我,直接把html parse了,用xpath搞定。
Matcher m = p.matcher(input);
if (m.matches()) {
int cnt = m.groupCount();
System.out.println(cnt);
String g1 = m.group(1);
System.out.println(g1);
String g2 = m.group(2);
System.out.println(g2);
}
发帖数: 65
发帖数: 9224
不要写regex, 这个我做过很多时间了。你会发现,你写了,就算没问题,将来维护也
麻烦。得不偿失哈。
我的经验总结。
不要写regex, 这个我做过很多时间了。你会发现,你写了,就算没问题,将来维护也
麻烦。得不偿失哈。
我的经验总结。
。