code: public void replace(StringBuilder sb, CharSequence text)
      {
          if (!isCompiled())
          {
              compile();
          }
          DFAState<Replacer> st = root;
          Replacer replacer = null;
          int start = -1;
          int end = -1;
          int len = text.length();
          for (int ii=0;ii<len;ii++)
          {
              char cc = text.charAt(ii);
              st = st.transit(cc);
              if (st != null)
              {
                  if (start == -1)
                  {
                      start = ii; // start of match
                  }
                  if (st.isAccepting())
                  {
                      end = ii;   // last accpting point
                      replacer = st.getToken();
                  }
              }
              else
              {
                  // error
                  if (start != -1)
                  {
                      // we have some matching
                      if (end != -1)
                      {
                          // accepted string
                          replacer.replace(sb, text, start, end+1);
                          ii = end;   // reparse after last match
                          end = -1;
                      }
                      else
                      {
                          // not accepted partial match
                          sb.append(text, start, ii+1);
                      }
                      start = -1;
                  }
                  else
                  {
                      sb.append(cc);
                  }
                  st = root;
              }
          }
          if (start != -1)
          {
              // matching at end
              if (end != -1)
              {
                  replacer.replace(sb, text, start, end+1);
              }
              else
              {
                  sb.append(text, start, len);
              }
          }
      }
docs: Compiles if not compiled. Replaces found string by using attached replacers.
  
  <p>This method is thread safe:
  @param sb
  @param text