support for CAPTCHAs
[mir.git] / source / mir / util / StringRoutines.java
index 6757bdf..55d5edf 100755 (executable)
@@ -29,7 +29,7 @@
  */
 package mir.util;
 
-import gnu.regexp.RE;
+import org.apache.oro.text.regex.*;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -85,8 +85,6 @@ public class StringRoutines {
 
     return result.toString();
   }
-  /**
-   */
 
   public static String replaceEscapedStringCharacters(String aText, char anEscapeCharacter, char[] aCharactersToReplace, String[] aStringsToSubstitute) {
     if (aText==null)
@@ -158,14 +156,13 @@ public class StringRoutines {
 
   public static String performRegularExpressionReplacement(String aSource, String aSearchExpression, String aReplacement) {
     try {
-      RE regularExpression;
-
-      regularExpression = new RE(aSearchExpression);
+      Pattern pattern = new Perl5Compiler().compile(aSearchExpression);
 
-      return regularExpression.substituteAll(aSource, aReplacement);
+      return Util.substitute(
+              new Perl5Matcher(), pattern, new Perl5Substitution(aReplacement), aSource, Util.SUBSTITUTE_ALL);
     }
-    catch (Throwable t) {
-      throw new UtilFailure("StringRoutines.performRegularExpressionReplacement: " + t.toString(), t);
+    catch (MalformedPatternException t) {
+      throw new UtilFailure("Invalid regular expression", t);
     }
   }