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

void PString::Replace ( const PString target,
const PString subs,
BOOL  all = FALSE,
PINDEX  offset = 0 
) [inherited]

Locate the substring within the string and replace it with the specifed substring. The search will begin at the character offset provided.

If offset# is beyond the length of the string, then the function will do nothing.

The matching will be for identical character or string. If a search ignoring case is required then the string should be converted to a PCaselessString# before the search is made.

Parameters:
targetText to be removed.
subsString to be inserted into the gaps created
allReplace all occurrences of target text.
offsetOffset into string to begin search.

Definition at line 2088 of file contain.cxx.

References PString::Find(), PString::GetLength(), PString::MakeUnique(), and PString::Splice().

Referenced by PRegisterPage::LoadText(), and PHTTPConfigSectionList::OnLoadedText().

{
  if (offset < 0)
    return;
    
  MakeUnique();

  PINDEX tlen = target.GetLength();
  PINDEX slen = subs.GetLength();
  do {
    PINDEX pos = Find(target, offset);
    if (pos == P_MAX_INDEX)
      return;
    Splice(subs, pos, tlen);
    offset = pos + slen;
  } while (all);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index