一个正则表达式。 和一个配置文件格式

2 views
Skip to first unread message

lizo...@gmail.com

unread,
Feb 18, 2006, 10:59:18 AM2/18/06
to lizongbo
ÓÃÓÚubb×Ö·û´®ÄÚÈÝÌæ»»¡£


import java.util.regex.*;

public class MyDemo {


public static void main(String[] args) {
String str = "[img]http://xxxxx.com/xxxx1.jpg[/img]" +
"[img]http://xxxxx.com/xxxx2.jpg [/img]" +
"[img]http://xxxxx.com/xxxx3.jpg [/img]" +
"[img]http://xxxxx.com/xxxx4.jpg [/img]" +
"[img]http://xxxxx.com/xxxx5.jpg [/img]" +
"[img]http://xxxxx.com/xxxx6.jpg [/img]";
System.out.println(str.replaceAll("\\[img](.*?)\\[/img]",
"$1\n"));
}
}


¹Ø¼ü´Ê¹ýÂËÎļþ¸ñʽ£º

<?xml version="1.0" encoding="UTF-8"?>
<!--¶¨ÒåÒ»¸ö´æ·Å¹ýÂ˴ʵÄÅäÖÃÎļþ-->
<filterwords>
<!--°´¿ªÍ·Æ¥Åä-->
<beginwith>1,2,3,</beginwith>
<!--°´½áβƥÅä-->
<endwith>4,5,6</endwith>
<!--°´²éÕÒ¶¨Î»Æ¥Åä-->
<indexof>7,8,9</indexof>
<!--°´ÕýÔò±í´ïʽƥÅ䣬ÕýÔò±í´ïʽÀàÐ͵ĹýÂ˴ʽ¨Ò鲻Ҫ̫¶à-->
<regex>123456</regex>
</filterwords>

Reply all
Reply to author
Forward
0 new messages