You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by Surfbird Fang <su...@hotmail.com> on 2001/10/09 13:47:18 UTC
Substitute " " for with the AwkTools regular expression classes, Some trouble?
When I want to subsitute " " for in a html file with AWK, I write the following code.But some trouble arise.
Then console report the error message :
java.lang.ArrayIndexOutOfBoundsException
at org.apache.oro.text.awk.AwkMatcher._search(AwkMatcher.java:717)
at org.apache.oro.text.awk.AwkMatcher.contains(AwkMatcher.java:622)
at test.Test.removeBlankspaceEntity(Test.java:58)
at test.Test.<init>(Test.java:27)
at test.Test.main(Test.java:82)
the code following
============================
String regex = "( )";
String sentence=null;
AwkMatcher matcher;
AwkCompiler compiler;
Pattern pattern = null, blankspace = null;
AwkStreamInput input;
MatchResult result;
Reader file = null;
// Create AwkCompiler and AwkMatcher instances.
compiler = new AwkCompiler();
matcher = new AwkMatcher();
pattern = compiler.compile(regex, AwkCompiler.CASE_INSENSITIVE_MASK);
blankspace = compiler.compile("( )");
file = new FileReader(src);
input = new AwkStreamInput(file);
while(matcher.contains(input, pattern)) {
result = matcher.getMatch();
sentence = Util.substitute(matcher, blankspace,
new StringSubstitution(" "),
result.toString(), Util.SUBSTITUTE_ALL);
}
==================================
What happen? Do I write regular expression error?
Thanks in advance
Surfbird