CMS  Version 3.9
ParseMaster Class Reference

Public Member Functions

 add ($expression, $replacement='')
 
 exec ($string)
 
 reset ()
 

Public Attributes

 $ignoreCase = false
 
 $escapeChar = ''
 
const EXPRESSION = 0
 
const REPLACEMENT = 1
 
const LENGTH = 2
 

Detailed Description

Definition at line 545 of file javascript_packer.inc.

Member Function Documentation

◆ add()

ParseMaster::add (   $expression,
  $replacement = '' 
)

Definition at line 563 of file javascript_packer.inc.

563  {
564  // count the number of sub-expressions
565  // - add one because each pattern is itself a sub-expression
566  $length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string)$expression), $out);
567 
568  // treat only strings $replacement
569  if (is_string($replacement)) {
570  // does the pattern deal with sub-expressions?
571  if (preg_match($this->SUB_REPLACE, $replacement)) {
572  // a simple lookup? (e.g. "$2")
573  if (preg_match($this->INDEXED, $replacement)) {
574  // store the index (used for fast retrieval of matched strings)
575  $replacement = (int)(substr($replacement, 1)) - 1;
576  } else { // a complicated lookup (e.g. "Hello $2 $1")
577  // build a function to do the lookup
578  $quote = preg_match($this->QUOTE, $this->_internalEscape($replacement))
579  ? '"' : "'";
580  $replacement = array(
581  'fn' => '_backReferences',
582  'data' => array(
583  'replacement' => $replacement,
584  'length' => $length,
585  'quote' => $quote
586  )
587  );
588  }
589  }
590  }
591  // pass the modified arguments
592  if (!empty($expression)) $this->_add($expression, $replacement, $length);
593  else $this->_add('/^$/', $replacement, $length);
594  }
$out
Definition: page.inc:66

◆ exec()

ParseMaster::exec (   $string)

Definition at line 596 of file javascript_packer.inc.

596  {
597  // execute the global replacement
598  $this->_escaped = array();
599 
600  // simulate the _patterns.toSTring of Dean
601  $regexp = '/';
602  foreach ($this->_patterns as $reg) {
603  $regexp .= '(' . substr($reg[self::EXPRESSION], 1, -1) . ')|';
604  }
605  $regexp = substr($regexp, 0, -1) . '/';
606  $regexp .= ($this->ignoreCase) ? 'i' : '';
607 
608  $string = $this->_escape($string, $this->escapeChar);
609  $string = preg_replace_callback(
610  $regexp,
611  array(
612  &$this,
613  '_replacement'
614  ),
615  $string
616  );
617  $string = $this->_unescape($string, $this->escapeChar);
618 
619  return preg_replace($this->DELETED, '', $string);
620  }

◆ reset()

ParseMaster::reset ( )

Definition at line 622 of file javascript_packer.inc.

622  {
623  // clear the patterns collection so that this object may be re-used
624  $this->_patterns = array();
625  }

Member Data Documentation

◆ $escapeChar

ParseMaster::$escapeChar = ''

Definition at line 547 of file javascript_packer.inc.

◆ $ignoreCase

ParseMaster::$ignoreCase = false

Definition at line 546 of file javascript_packer.inc.

◆ EXPRESSION

const ParseMaster::EXPRESSION = 0

Definition at line 550 of file javascript_packer.inc.

◆ LENGTH

const ParseMaster::LENGTH = 2

Definition at line 552 of file javascript_packer.inc.

◆ REPLACEMENT

const ParseMaster::REPLACEMENT = 1

Definition at line 551 of file javascript_packer.inc.


The documentation for this class was generated from the following file: