/*
 * Copyright 2000-2010 JetBrains s.r.o.
 *
 * 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.
 */
package com.intellij.codeInsight.template.zencoding;

import com.intellij.openapi.util.Pair;

/**
 * @author Eugene.Kudelevsky
 */
public class ZenCodingUtil {
  static final String NUMBER_IN_ITERATION_PLACE_HOLDER = "$";

  public static String getValue(Pair<String, String> pair, int numberInIteration) {
    String s = pair.second.replace(NUMBER_IN_ITERATION_PLACE_HOLDER, Integer.toString(numberInIteration + 1));
    return s.replace("\"", "&quot;");
  }
}

@@ -756,16 +756,24 @@
 til %7B%0A  
+private 
 static f
@@ -781,54 +781,744 @@
 nal 
-String NUMBER_IN_ITERATION_PLACE_HOLDER = %22$%22;
+char NUMBER_IN_ITERATION_PLACE_HOLDER = '$';%0A%0A  private ZenCodingUtil() %7B%0A  %7D%0A%0A  private static String replaceNumberMarkersBy(String s, String by) %7B%0A    StringBuilder builder = new StringBuilder(s.length());%0A    int j = -1;%0A    for (int i = 0, n = s.length(); i %3C= n; i++) %7B%0A      char c = i %3C n ? s.charAt(i) : 0;%0A      if (c == NUMBER_IN_ITERATION_PLACE_HOLDER) %7B%0A        if (j == -1) %7B%0A          j = i;%0A        %7D%0A      %7D%0A      else %7B%0A        if (j != -1) %7B%0A          for (int k = 0, m = i - j - by.length(); k %3C m; k++) %7B%0A            builder.append('0');%0A          %7D%0A          builder.append(by);%0A          j = -1;%0A        %7D%0A        if (i %3C n) %7B%0A          builder.append(c);%0A        %7D%0A      %7D%0A    %7D%0A    return builder.toString();%0A  %7D
 %0A%0A  
@@ -1618,60 +1618,42 @@
 s = 
-pair.second.replace(NUMBER_IN_ITERATION_PLACE_HOLDER
+replaceNumberMarkersBy(pair.second
 , In

support for sequences of number markers