diff --git a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Group.xml b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Group.xml
index 09a2abf..c54f912 100644
--- a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Group.xml
+++ b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Group.xml
@@ -1,4 +1,4 @@
-
+
+
+
+ CS2JNet.System.Text.RegularExpressions.GroupCollection
+
+ GroupCollection
+ System.Text.RegularExpressions.GroupCollection
+
+
+ System.Collections.ICollection
+
+
+
+
+
+
+
+
+
+ System.Int32
+ key
+
+
+ System.Text.RegularExpressions.Group
+ ${this:16}.get(${key})
+
+
+
+ CS2J does not yet support Named groups in Regular Expressions
+
+
+ System.String
+ key
+
+
+ System.Text.RegularExpressions.Group
+ ${this:16}.get(${key})
+
+
+
+
+
+
+
+
+/NAwgdUvZuJRzEnlky9ue6sLWIc=AVizzM2k9+WSxJekoW45/t/cpEHgGLy2wYWAC9lirjVkTSEkvg+uhCM32tV+6WS4kLUWUPkvAADftndYCs/OI07BLrBG5y/OBFJSs22Aks1P8h972Q33FMPKZfrf7pVR+hhYSQuJPyLxIy0pLBXWOicqlk0jmuojI1oYYGH9+rE=
diff --git a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Match.xml b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Match.xml
index b9e1626..b4f9a8f 100644
--- a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Match.xml
+++ b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Match.xml
@@ -1,4 +1,4 @@
-
+
- java.util.regex.*
+ CS2JNet.System.Text.RegularExpressions.Match
- Matcher
+ Match
System.Text.RegularExpressions.Match
System.Text.RegularExpressions.Group
-
-
+
+
+ ${this:16}.nextMatch()
+
+
+ NextMatch
+ System.Text.RegularExpressions.Match
+
+
+
+
+
+ CS2JNet.System.Text.RegularExpressions.GroupCollection
+
+ System.Text.RegularExpressions.GroupCollection
+ Groups
+ GroupCollection.mk(${this})
+
+
+ System.Int32
+ Length
+ ${this}.length()
+
+
+
+ System.String
+ Value
+ ${this:16}.getValue()
+
+
+
+ System.Bool
+ Success
+ ${this:16}.getSuccess()
+
+
diff --git a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/MatchCollection.xml b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/MatchCollection.xml
new file mode 100644
index 0000000..aa74a23
--- /dev/null
+++ b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/MatchCollection.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ java.util.List
+ CS2JNet.System.Text.RegularExpressions.Match
+
+ List*[Match]*
+ System.Text.RegularExpressions.MatchCollection
+
+
+ System.Collections.Generic.IList*[System.Text.RegularExpressions.Match]*
+
+
+
+
+
+
+
+
+
+
+
+
+/NAwgdUvZuJRzEnlky9ue6sLWIc=AVizzM2k9+WSxJekoW45/t/cpEHgGLy2wYWAC9lirjVkTSEkvg+uhCM32tV+6WS4kLUWUPkvAADftndYCs/OI07BLrBG5y/OBFJSs22Aks1P8h972Q33FMPKZfrf7pVR+hhYSQuJPyLxIy0pLBXWOicqlk0jmuojI1oYYGH9+rE=
diff --git a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Regex.xml b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Regex.xml
index e200442..4ef5a67 100644
--- a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Regex.xml
+++ b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/Regex.xml
@@ -1,4 +1,4 @@
-
+
- java.util.regex.*
+ java.util.regex.Pattern
Pattern
System.Text.RegularExpressions.Regex
@@ -17,8 +17,10 @@
System.Object
-
- ${this:16}.matcher(${input})
+
+ CS2JNet.System.Text.RegularExpressions.Match
+
+ Match.mk(${this}, ${input})
System.String
@@ -28,6 +30,38 @@
Match
System.Text.RegularExpressions.Match
+
+
+ CS2JNet.System.Text.RegularExpressions.Match
+
+ Match.mk(${this}, ${input}, ${startat})
+
+
+ System.String
+ input
+
+
+ System.Int32
+ startat
+
+
+ Match
+ System.Text.RegularExpressions.Match
+
+
+
+ CS2JNet.System.Text.RegularExpressions.Match
+
+ Match.mkMatches(${this}, ${input})
+
+
+ System.String
+ input
+
+
+ Matches
+ System.Collections.Generic.Collection*[Match]*
+
${this:16}.matcher(${input}).matches()
@@ -42,7 +76,7 @@
- java.util.regex.*
+ java.util.regex.Pattern
Pattern.compile(${pattern}).matcher(${input}).matches()
@@ -60,7 +94,7 @@
- java.util.regex.*
+ java.util.regex.Pattern
Pattern.compile(${pattern}).matcher(${input}).replaceAll(${replacement})
@@ -87,14 +121,14 @@
- java.util.regex.*
+ java.util.regex.Pattern
new Pattern()
- java.util.regex.*
+ java.util.regex.Pattern
Pattern.compile(${pattern})
@@ -104,6 +138,22 @@
+
+
+ java.util.regex.Pattern
+
+ Pattern.compile(${pattern}, ${options})
+
+
+ System.String
+ pattern
+
+
+ System.Text.RegularExpressions.RegexOptions
+ options
+
+
+
diff --git a/CS2JLibrary/NetFramework/System/Text/RegularExpressions/RegexOptions.xml b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/RegexOptions.xml
new file mode 100644
index 0000000..888c7c3
--- /dev/null
+++ b/CS2JLibrary/NetFramework/System/Text/RegularExpressions/RegexOptions.xml
@@ -0,0 +1,63 @@
+
+
+
+
+ CS2JNet.System.Text.RegularExpressions.RegexOptions
+
+ int
+ System.Text.RegularExpressions.RegexOptions
+
+ System.Enum
+
+
+
+ 0 /* RegexOptions.None */
+ None
+
+
+ java.util.regex.Pattern
+ Pattern.CASE_INSENSITIVE
+ IgnoreCase
+
+
+ java.util.regex.Pattern
+ Pattern.MULTILINE
+ Multiline
+
+
+ ${this:16}.ExplicitCapture
+ ExplicitCapture
+
+
+ 0 /* RegexOptions.Compiled */
+ Compiled
+
+
+ ${this:16}.Singleline
+ Singleline
+
+
+ ${this:16}.IgnorePatternWhitespace
+ IgnorePatternWhitespace
+
+
+ ${this:16}.RightToLeft
+ RightToLeft
+
+
+ ${this:16}.ECMAScript
+ ECMAScript
+
+
+ ${this:16}.CultureInvariant
+ CultureInvariant
+
+
+mo6ChmPjcAlAo0NBWLLZbsocykw=RlUioSuamZxr9dmH+n+zDAoS31RAR3VRqGwbq0J8Ew28sRdZoXTjz2yJwWvSZIzMRNeMc0v8VZbLRMEM39bSKH51gWKuQ8TFyzTBwMzQDeDsNO5kzdxcE1DYGnZKKplPDKPM8n9mlpuDYginKU8dk3dA/CtPgAmc7X90AuPIhew=
diff --git a/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/Group.java b/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/Group.java
new file mode 100644
index 0000000..cc3d577
--- /dev/null
+++ b/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/Group.java
@@ -0,0 +1,67 @@
+/*
+ Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Author(s):
+
+ Kevin Glynn (kevin.glynn@twigletsoftware.com)
+*/
+
+package CS2JNet.System.Text.RegularExpressions;
+
+import java.util.regex.Matcher;
+
+/**
+ * @author keving
+ *
+ */
+public class Group {
+
+ private Match match = null;
+ private int index = -1;
+ /**
+ * @return the matcher
+ */
+ public Match getMatch() {
+ return match;
+ }
+ /**
+ * @param matcher the matcher to set
+ */
+ public void setMatch(Match match) {
+ this.match = match;
+ }
+ /**
+ * @return the index
+ */
+ public int getIndex() {
+ return index;
+ }
+ /**
+ * @param index the index to set
+ */
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ /**
+ * @return the string matched by group
+ * If index is default then the whole match, else the group(index)
+ */
+ public String getValue() {
+ return (index >= 0 ? match.getMatcher().group(index) : match.getMatcher().group());
+ }
+
+
+}
diff --git a/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/GroupCollection.java b/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/GroupCollection.java
new file mode 100644
index 0000000..18ba0ad
--- /dev/null
+++ b/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/GroupCollection.java
@@ -0,0 +1,62 @@
+/*
+ Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Author(s):
+
+ Kevin Glynn (kevin.glynn@twigletsoftware.com)
+*/
+
+package CS2JNet.System.Text.RegularExpressions;
+
+import java.util.regex.Matcher;
+
+import CS2JNet.System.NotImplementedException;
+
+/**
+ * @author keving
+ *
+ */
+public class GroupCollection {
+
+ private Match match = null;
+
+ public static GroupCollection mk(Match m) {
+ GroupCollection ret = new GroupCollection();
+ ret.match = m;
+ return ret;
+ }
+
+ /***
+ *
+ * @param i
+ * @return
+ */
+ public Group get(int i) {
+ Group ret = new Group();
+ ret.setMatch(this.match);
+ ret.setIndex(i);
+ return ret;
+ }
+
+ /***
+ *
+ * @param name
+ * @return
+ * @throws NotImplementedException
+ */
+ public Group get(String name) throws NotImplementedException {
+ throw new NotImplementedException("CS2J: No implementation for named groups in regular expressions");
+ }
+}
diff --git a/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/Match.java b/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/Match.java
new file mode 100644
index 0000000..d1d4c72
--- /dev/null
+++ b/CS2JLibrary/src/CS2JNet/System/Text/RegularExpressions/Match.java
@@ -0,0 +1,116 @@
+/*
+ Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Author(s):
+
+ Kevin Glynn (kevin.glynn@twigletsoftware.com)
+*/
+
+package CS2JNet.System.Text.RegularExpressions;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author keving
+ *
+ */
+public class Match {
+
+ private Matcher matcher = null;
+ private boolean lastMatchSuccess = false;
+ private int lastMatchStartIdx = 0;
+ private int lastMatchLength = 0;
+
+ private String input = "";
+ private Pattern pat = null;
+
+ /**
+ * @return the matcher
+ */
+ public Matcher getMatcher() {
+ return matcher;
+ }
+ /**
+ * @param matcher the matcher to set
+ */
+ public void setMatcher(Matcher matcher) {
+ this.matcher = matcher;
+ }
+
+ /**
+ * @return the string matched by the last match
+ */
+ public String getValue() {
+ return matcher.group();
+ }
+
+ /**
+ * @return the string matched by the last match
+ */
+ public boolean getSuccess() {
+ return lastMatchSuccess;
+ }
+
+ /**
+ * @return the length of string matched by the last match
+ */
+ public int length() {
+ return lastMatchLength;
+ }
+
+ /**
+ * @return the start index of string matched by the last match
+ */
+ public int start() {
+ return lastMatchStartIdx;
+ }
+
+ public Match nextMatch() {
+ return mk(this.pat, this.input,
+ this.lastMatchLength == 0 ? this.lastMatchStartIdx + 1 : this.lastMatchStartIdx + this.lastMatchLength);
+ }
+
+ public static Match mk(Pattern pat, String input, int startat) {
+ Match ret = new Match();
+ ret.pat = pat;
+ ret.input = input;
+ ret.matcher = pat.matcher(input);
+ ret.lastMatchSuccess = ret.matcher.find(startat);
+ if (ret.lastMatchSuccess) {
+ ret.lastMatchStartIdx = ret.matcher.start();
+ ret.lastMatchLength = ret.matcher.end() -ret.matcher.start();
+ }
+ return ret;
+ }
+
+ public static Match mk(Pattern pat, String input) {
+ return mk(pat, input, 0);
+ }
+
+ public static List mkMatches(Pattern pat, String input) {
+ List ret = new ArrayList();
+ Match m = mk(pat, input);
+ while (m.getSuccess()) {
+ ret.add(m);
+ m = m.nextMatch();
+ }
+ return ret;
+ }
+
+
+}
diff --git a/CSharpTranslator/tests/Tester/Main.cs b/CSharpTranslator/tests/Tester/Main.cs
index 7e6afdc..97597fe 100644
--- a/CSharpTranslator/tests/Tester/Main.cs
+++ b/CSharpTranslator/tests/Tester/Main.cs
@@ -16,6 +16,7 @@ namespace Tester
// Tester.Misc.RenameTest.RNMain("hello world");
Tester.Misc.Sorter.Example.SorterMain();
+ Tester.Misc.RegexTest.RegexMain();
}
}
diff --git a/CSharpTranslator/tests/Tester/Misc/Regex/RegexTest.cs b/CSharpTranslator/tests/Tester/Misc/Regex/RegexTest.cs
new file mode 100644
index 0000000..ec72d41
--- /dev/null
+++ b/CSharpTranslator/tests/Tester/Misc/Regex/RegexTest.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Text.RegularExpressions;
+
+namespace Tester.Misc
+{
+ public class RegexTest
+ {
+ public RegexTest ()
+ {
+ }
+
+ public static void RegexMain() {
+
+ Regex r = new Regex(@"(\d+)\s+(\d+)");
+ Match m = r.Match(" 001 002 003 004 ");
+ while (m.Success)
+ {
+ Console.WriteLine("Match: '{0}'", m.Value);
+ for (int i = 0; i < 3; i++) {
+ if (m.Groups[i] != null && m.Groups[i].Value.Length > 0)
+ {
+ Console.WriteLine("Group {0}: '{1}'", i, m.Groups[i].Value);
+ }
+ }
+
+ m = m.NextMatch();
+ }
+ MatchCollection matches = r.Matches(" 001 002 003 004 ");
+ foreach (Match mi in matches)
+ {
+ Console.WriteLine("Match: '{0}'", mi.Value);
+ for (int i = 0; i < 3; i++) {
+ if (mi.Groups[i] != null && mi.Groups[i].Value.Length > 0)
+ {
+ Console.WriteLine("Group {0}: '{1}'", i, mi.Groups[i].Value);
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/CSharpTranslator/tests/Tester/Tester.csproj b/CSharpTranslator/tests/Tester/Tester.csproj
index d6e651d..1afd67f 100644
--- a/CSharpTranslator/tests/Tester/Tester.csproj
+++ b/CSharpTranslator/tests/Tester/Tester.csproj
@@ -59,9 +59,11 @@
+
+
\ No newline at end of file