Logo Search packages:      
Sourcecode: yate version File versions  Download package

String String::replaceMatches ( const String templ  )  const

Create a string by replacing matched strings in a template

Parameters:
templ Template of the string to generate
Returns:
Copy of template with "\0" - "\9" replaced with submatches

Definition at line 690 of file String.cpp.

References find(), matchString(), and substr().

{
    String s;
    int pos, ofs = 0;
    for (;;) {
      pos = templ.find('\\',ofs);
      if (pos < 0) {
          s << templ.substr(ofs);
          break;
      }
      s << templ.substr(ofs,pos-ofs);
      pos++;
      char c = templ[pos];
      if (c == '\\') {
          pos++;
          s << "\\";
      }
      else if ('0' <= c && c <= '9') {
          pos++;
          s << matchString(c - '0');
      }
      else {
          pos++;
          s << "\\" << c;
      }
      ofs = pos;
    }
    return s;
}


Generated by  Doxygen 1.6.0   Back to index