close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": libgnutls-deb0.so.28: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Jul 4, 2008, 5:52:29 PM (17 years ago)
- Author:
-
waue
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
|
v10
|
v11
|
|
| 71 | 71 | {{{ |
| 72 | 72 | private static Pattern p = Pattern |
| 73 | | .compile("([^ ]*) ([^ ]*) ([^ ]*) \\[([^]]*)\\] \"([^\"]*)\"" + |
| 74 | | " ([^ ]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\".*"); |
| | 73 | .compile("([︿ ]*) ([︿ ]*) ([︿ ]*) \\[([︿]]*)\\] \"([︿\"]*)\"" + |
| | 74 | " ([︿ ]*) ([︿ ]*) \"([︿\"]*)\" \"([︿\"]*)\".*"); |
| 75 | 75 | }}} |
| 76 | 76 | 首先先宣告產生一個物件 [http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html java.util.regex.Pattern] |
| … |
… |
|
| 78 | 78 | Compiles the given regular expression into a pattern.[[br]] |
| 79 | 79 | 將正規表示式的字串當引數輸入之後,就可以得到一個p的Pattern物件,而此正規表示式:[[br]] |
| 80 | | '''([^ ]*) ([^ ]*) ([^ ]*) \\[([^]]*)\\] \"([^\"]*)\" ([^ ]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\".*''' [[br]] |
| | 80 | '''([︿ ]*) ([︿ ]*) ([︿ ]*) \\[([︿]]*)\\] \"([︿\"]*)\" ([︿ ]*) ([︿ ]*) \"([︿\"]*)\" \"([︿\"]*)\".*''' [[br]] |
| 81 | 81 | 若apache log範例為:[[br]] |
| 82 | 82 | 140.110.138.176 - - [02/Jul/2008:16:55:02 +0800] "GET /hbase-0.1.3.zip HTTP/1.0" 200 10249801 "-" "Wget/1.10.2" [[br]] |
| … |
… |
|
| 84 | 84 | |
| 85 | 85 | || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || |
| 86 | | || ([^ ]*) || ([^ ]*) || ([^ ]*) || \\[([^]]*)\\] || \"([^\"]*)\" || ([^ ]*) || ([^ ]*) || \"([^\"]*)\" || \"([^\"]*)\".* || |
| | 86 | || ([︿ ]*) || ([︿ ]*) || ([︿ ]*) || \\[([︿]]*)\\] || \"([︿\"]*)\" || ([︿ ]*) || ([︿ ]*) || \"([︿\"]*)\" || \"([︿\"]*)\".* || |
| 87 | 87 | || ip || - || - || 時間 || "http " || 回傳碼 || 長度 || "指引" || "代理器" || |
| 88 | 88 | || 140.110.138.176 || - || - || [02/Jul/2008:16:55:02 +0800] || "GET /hbase-0.1.3.zip HTTP/1.0" || 200 || 10249801 || " -" || "Wget/1.10.2" || |