replaceFirst() 공개 메소드

public replaceFirst ( java arg0 ) : global::java.lang.String
arg0 java
리턴 global::java.lang.String
예제 #1
0
		private string ReplaceGroupNumber (Matcher match,
			string reformattedPattern,
			PatternGrouping patternGrouping,
			RegexOptions options) {
			int groupNumber = int.Parse (match.group (1));
			int javaGroupNumber = groupNumber;
			int groupCount = patternGrouping.GroupCount;

			if (groupCount == -1) {
				if ((options & RegexOptions.ExplicitCapture) == RegexOptions.ExplicitCapture) {
					groupCount = 0;
				}
				else {
					groupCount = JavaUtils.GroupCount (reformattedPattern);
				}
			}
			else {
				javaGroupNumber = patternGrouping.NetToJavaNumbersMap [groupNumber];
			}

			if (groupNumber > groupCount) {
				return null;
			}

			return match.replaceFirst (@"\\" + javaGroupNumber);
		}
예제 #2
0
		private string ReplaceGroupName (Matcher match,
			string reformattedPattern,
			PatternGrouping patternGrouping,
			RegexOptions options) {

			if (patternGrouping.GroupCount == -1){
				return null;
			}

			string groupName = match.group (1);
			Pattern p = Pattern.compile (NUMBER);
			Matcher m = p.matcher ((CharSequence) (object) groupName);
			if (m.matches ()) {
				return ReplaceGroupNumber (match, reformattedPattern, patternGrouping, options);
			}

			if (!patternGrouping.GroupNameToNumberMap.Contains (groupName)) {
				return null;
			}

			int javaGroupNumber = patternGrouping.NetToJavaNumbersMap [(int) patternGrouping.GroupNameToNumberMap [groupName]];
			return match.replaceFirst (@"\\" + javaGroupNumber);
		}