[minijoe] r74 committed - Added support for non-REGEXP String.replace() in JsObject.java

2 views
Skip to first unread message

min...@googlecode.com

unread,
Jul 23, 2010, 6:46:01 PM7/23/10
to min...@googlegroups.com
Revision: 74
Author: orientalsensation
Date: Fri Jul 23 15:45:34 2010
Log: Added support for non-REGEXP String.replace() in JsObject.java
http://code.google.com/p/minijoe/source/detail?r=74

Modified:
/trunk/src/com/google/minijoe/sys/JsObject.java

=======================================
--- /trunk/src/com/google/minijoe/sys/JsObject.java Sun Mar 15 17:00:41 2009
+++ /trunk/src/com/google/minijoe/sys/JsObject.java Fri Jul 23 15:45:34 2010
@@ -783,8 +783,24 @@
stack.getString(sp).compareTo(stack.getString(sp + 2)));
break;

- case ID_MATCH:
case ID_REPLACE:
+ s = stack.getString(sp);
+ find = stack.getString(sp + 2);
+ String replace = stack.getString(sp + 3);
+ if(!find.equals("")) {
+ StringBuffer sb = new StringBuffer(s);
+ int length = find.length();
+
+ // Parse nodes into vector
+ while ((index = sb.toString().indexOf(find)) >= 0) {
+ sb.delete(index, index + length);
+ sb.insert(index, replace);
+ }
+ stack.setObject(sp, sb.toString());
+ sb = null;
+ }
+ break;
+ case ID_MATCH:
case ID_SEARCH:
throw new RuntimeException("Regexp NYI");

Reply all
Reply to author
Forward
0 new messages