Function __global->comcode_preg_replace

Definitions

sources/comcode_from_html.php

  • Do a regular expression match, locked correctly to single Comcode elements. This is necessary to make sure nesting is handled correctly, which regular expressions cannot do on their own.This is a good test case:exit(comcode_preg_replace('test','#\[test\](.*)\[/test\]#','>${1}<','[test]x[test a]y[/test]z[/test]'));
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$element string No No required parameter N/A N/A The element name to replace over
$pattern string No No required parameter N/A N/A Pattern
$replacement mixed No No required parameter N/A N/A Replacement (string or single element array specifying a function name)
$semihtml string No No required parameter N/A N/A Haystack

Returns

  • Result
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Do a regular expression match, locked correctly to single Comcode elements. This is necessary to make sure nesting is handled correctly, which regular expressions cannot do on their own.This is a good test case:exit(comcode_preg_replace('test','#\[test\](.*)\[/test\]#','>${1}<','[test]x[test a]y[/test]z[/test]'));
 *
 * @param  string $element The element name to replace over
 * @param  string $pattern Pattern
 * @param  mixed $replacement Replacement (string or single element array specifying a function name)
 * @param  string $semihtml Haystack
 * @return string Result
 */

function comcode_preg_replace(string $element, string $pattern, $replacement, string $semihtml) : string