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

PString PRegularExpression::EscapeString ( const PString str ) [static]

Escape all characters in the str# parameter that have a special meaning within a regular expression.

String with additional escape ('\') characters.
strString to add esacpes to.

Definition at line 3302 of file contain.cxx.

References PString::FindOneOf(), and PString::Mid().

  PString translated;

  PINDEX lastPos = 0;
  PINDEX nextPos;
  while ((nextPos = str.FindOneOf("\\^$+?*.[]()|{}", lastPos+1)) != P_MAX_INDEX) {
    translated += str(lastPos, nextPos-1) + "\\";
    lastPos = nextPos;

  if (lastPos == 0)
    return str;

  return translated + str.Mid(lastPos);

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index