Same name in other branches
- 5.0.x advagg_js_minify/jspacker.inc \ParseMaster::add()
- 6.0.x advagg_js_minify/jspacker.inc \ParseMaster::add()
- 7.x-2.x advagg_js_compress/jspacker.inc \ParseMaster::add()
- 8.x-2.x advagg_js_minify/jspacker.inc \ParseMaster::add()
- 8.x-3.x advagg_js_minify/jspacker.inc \ParseMaster::add()
- 8.x-4.x advagg_js_minify/jspacker.inc \ParseMaster::add()
Fichier
-
advagg_js_compress/
jspacker.inc, line 579
Classe
Code
public function add($expression, $replacement = '') {
// count the number of sub-expressions
// - add one because each pattern is itself a sub-expression
$length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string) $expression), $out);
// treat only strings $replacement
if (is_string($replacement)) {
// does the pattern deal with sub-expressions?
if (preg_match($this->SUB_REPLACE, $replacement)) {
// a simple lookup? (e.g. "$2")
if (preg_match($this->INDEXED, $replacement)) {
// store the index (used for fast retrieval of matched strings)
$replacement = (int) substr($replacement, 1) - 1;
}
else {
// a complicated lookup (e.g. "Hello $2 $1")
// build a function to do the lookup
$quote = preg_match($this->QUOTE, $this->_internalEscape($replacement)) ? '"' : "'";
$replacement = array(
'fn' => '_backReferences',
'data' => array(
'replacement' => $replacement,
'length' => $length,
'quote' => $quote,
),
);
}
}
}
// pass the modified arguments
if (!empty($expression)) {
$this->_add($expression, $replacement, $length);
}
else {
$this->_add('/^$/', $replacement, $length);
}
}