1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
diff --git a/contrib/src/java/org/jdom/contrib/beans/DateUtils.java b/contrib/src/java/org/jdom/contrib/beans/DateUtils.java
index 49f26c4..7d8e590 100644
--- a/contrib/src/java/org/jdom/contrib/beans/DateUtils.java
+++ b/contrib/src/java/org/jdom/contrib/beans/DateUtils.java
@@ -59,7 +59,7 @@
package org.jdom.contrib.beans;
import java.util.*;
-import org.apache.regexp.*;
+import java.util.regex.*;
import java.text.*;
import java.io.PrintStream;
@@ -165,20 +165,20 @@ public class DateUtils {
// e.g. 1997-07-16T19:20:30.45+01:00
// additions: "T" can be a space, TZ can be a three-char code, TZ can be missing
try {
- RE re = new RE(reISO8601);
- if (re.match(s)) {
+ Matcher re = Pattern.compile(reISO8601).matcher(s);
+ if (re.find()) {
if (debug)
showParens(re);
ISO8601 iso = new ISO8601();
- iso.year = toInt(re.getParen(1));
- iso.month = toInt(re.getParen(3));
- iso.day = toInt(re.getParen(5));
- iso.hour = toInt(re.getParen(7));
- iso.min = toInt(re.getParen(8));
- iso.sec = toInt(re.getParen(11));
- iso.frac = toInt(re.getParen(13));
- iso.tz = re.getParen(14);
+ iso.year = toInt(re.group(1));
+ iso.month = toInt(re.group(3));
+ iso.day = toInt(re.group(5));
+ iso.hour = toInt(re.group(7));
+ iso.min = toInt(re.group(8));
+ iso.sec = toInt(re.group(11));
+ iso.frac = toInt(re.group(13));
+ iso.tz = re.group(14);
if (debug) {
System.out.println("year='" + iso.year + "'");
@@ -194,7 +194,7 @@ public class DateUtils {
return iso;
}
} // try
- catch (RESyntaxException ree) {
+ catch (PatternSyntaxException ree) {
ree.printStackTrace();
}
return null;
@@ -214,13 +214,13 @@ public class DateUtils {
* Dump parenthesized subexpressions found by a regular expression matcher object
* @param r Matcher object with results to show
*/
- static void showParens(RE r)
+ static void showParens(Matcher r)
{
// Loop through each paren
- for (int i = 0; i < r.getParenCount(); i++)
+ for (int i = 0; i < r.groupCount(); i++)
{
// Show paren register
- System.out.println("$" + i + " = " + r.getParen(i));
+ System.out.println("$" + i + " = " + r.group(i));
}
}
diff --git a/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java b/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java
index b7a4d5a..d0851d3 100644
--- a/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java
+++ b/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java
@@ -63,8 +63,7 @@ import org.jdom.xpath.XPath;
import org.xml.sax.Attributes;
-import org.apache.regexp.RE;
-import org.apache.regexp.RESyntaxException;
+import java.util.regex.*;
/* package */ class JakartaRegExpXPathMatcher extends XPathMatcher {
@@ -72,7 +71,7 @@ import org.apache.regexp.RESyntaxException;
/**
* The compiled regular expression this matcher matches.
*/
- private final RE re;
+ private final Pattern re;
private final XPath test;
@@ -94,7 +93,7 @@ import org.apache.regexp.RESyntaxException;
try {
String pathPattern = getPathPatternAsRE(expression);
- this.re = new RE(pathPattern);
+ this.re = Pattern.compile(pathPattern);
String testPattern = getTestPattern(expression);
if (testPattern != null) {
@@ -114,7 +113,7 @@ import org.apache.regexp.RESyntaxException;
" -> XPath = " + testPattern);
}
}
- catch (RESyntaxException ex1) {
+ catch (PatternSyntaxException ex1) {
throw (new JDOMException(
"Illegal XPath expression: " + expression, ex1));
}
@@ -137,7 +136,7 @@ import org.apache.regexp.RESyntaxException;
* expression, <code>false</code> otherwise.
*/
public boolean match(String path, Attributes attrs) {
- return (this.re.match(path));
+ return (this.re.matcher(path).find());
}
/**
|