Replace tags in string using {tag}
@param  string $str
@param  array $tags
@return string
556111
public function replaceTags($str, $tags)
    {
        return preg_replace_callback(
            '/\\{([^{}]+)\}/',
            function ($matches) use ($tags) {
                return array_key_exists($matches[1], $tags)
                ? $tags[$matches[1]]
                : '';
            },
            $str
        );
    }
87412
public function insertOrReplace($columns, $tags, $parameters = array()) {
        if (!empty($columns) && strpos($columns, '(') === false) {
            $columns = '('.$columns.')';
        }
        $tags = trim($tags);
        if (strpos($tags, '(') !== 0) {
            $tags = '('.$tags.')';
        }
        return $this->update("REPLACE INTO {$this->table} {$columns} VALUES {$tags}", $parameters);
    }
1348611
public static function replace_sources($tag, $sources) {
        $tag = self::remove_attributes($tag, 'src');
        $tag = preg_replace(['~</?source\b[^>]*>~i'], '', $tag);
        if (preg_match('/^(<.*?>)([^\0]*)$/ms', $tag, $matches)) {
            $tag = $matches[1].$sources.$matches[2];
        }
        return $tag;
    }
152265
public function replace($tags)
    {
        foreach ($tags as $tag) {
            if (!$tag instanceof Tag) {
                throw InvalidTagException::build([], ['invalidTag' => $tag]);
            }
        }

        parent::replace($tags);
    }
149570
static function strReplace($str,$params)
    {
        foreach ($params as $k=>$v) {
            $str = str_replace($k, $v, $str);
        }
        return $str;
    }
669297
function clean($arg,$tags=NULL) {
		$fw=$this;
		return $this->recursive($arg,
			function($val) use($fw,$tags) {
				if ($tags!='*')
					$val=trim(strip_tags($val,
						'<'.implode('><',$fw->split($tags)).'>'));
				return trim(preg_replace(
					'/[\x00-\x08\x0B\x0C\x0E-\x1F]/','',$val));
			}
		);
	}
332963
private function _buildTag($str, $tagname)
        {
//          $tagname = $this->_options['tag_name'];
            $tag = array(
                'block'         => $str,
                'content'       => '',
                'name'          => '',
                'attributes'    => array()
            );
            $begin_len = strlen(self::$tag_open.$tagname.':');
//          echo substr($str, 0, $begin_len)."\r\n";
            if(substr($str, 0, $begin_len) !== self::$tag_open.$tagname.':')
            {
//              closing tag
                $tag['name'] = '___text';
                return $tag;
            }
            else if(substr($str, 1, 1) === '/')
            {
//              closing tag
                $tag['name'] = '---ERROR---';
                return $tag;
            }
            else
            {
//              opening tag
                $matches = array();
//              check to see if this is a full tag or an openclose tag
                $has_closing_tag = substr($tag['block'], -2) !== '/'.self::$tag_close;
//              perform data matches
                if($has_closing_tag === true)
                {
                    $preg = '!(\\'.self::$tag_open.$tagname.':([_\-A-Za-z0-9]*)[^\\'.self::$tag_close.']*\\'.self::$tag_close.'| \/\\'.self::$tag_close.').*\\'.self::$tag_open.'\/'.$tagname.':[_\-A-Za-z0-9]*\\'.self::$tag_close.'!is';
//                  $preg = '!(\<'.$tagname.':([_\-A-Za-z0-9]*)[^\>]*\>| \/\>).*\<\/'.$tagname.':[_\-A-Za-z0-9]*\>!is';
                }
                else
                {
                    $preg = '!(\\'.self::$tag_open.$tagname.':([_\-A-Za-z0-9]*)([^\\'.self::$tag_close.']*))!is';
//                  $preg = '!(\<'.$tagname.':([_\-A-Za-z0-9]*)([^\/\>]*))!is';
                }
                
                if(preg_match_all($preg, $tag['block'], $matches) > 0)
                {
//                  get the tag type
                    $tag['name']    = $matches[2][0];
                
//                  get the tag inner content
                    $tag['content'] = '';
                    $tag['vars'] = false;
                    $attribute_string = $matches[1][0];
                    if($has_closing_tag === true)
                    {
                        $begin_len      = strlen($matches[1][0]);
                        $end_len = $has_closing_tag ? strlen(self::$tag_open.'/'.$tagname.':'.$tag['name'].self::$tag_close) : 0;
                        $tag['content'] = substr($str, $begin_len, strlen($matches[0][0])-$begin_len-$end_len);
//                      get hash tags vars?
                        if($this->_options['hash_tags'] === true && preg_match_all('/#{([^}]+)?}/i', $tag['content'], $vars) > 0)
                        {                       
                            $variables = array();
                            foreach ($vars[0] as $key => $var)
                            {
                                $variables[$var] = $vars[1][$key]; 
                            }
                            $tag['vars'] = $variables;
                        }
                    }
                    else
                    {
                        $attribute_string = rtrim($attribute_string, '/ ');
                    }
                    
//                  get the attributes
                    $attributes = array();
//                  preg_match_all("/([_\-A-Za-z0-9]*)((=\"|='))([\w\W\s]*)(\"|')/", $opener, $attributes);
//                  preg_match_all("/([_\-A-Za-z0-9]*)((=\"|='))([_\-A-Za-z0-9]*)(\"|')/", $opener, $atts);
//                  $result = preg_match_all("!([_\-A-Za-z0-9]*)(=\"|=')([\#\s\:\.\?\&\=\%\+\,\@\_\-A-Za-z0-9]*)(\"|')!is", $matches[1][0], $attributes);
                    if(preg_match_all("!([_\-A-Za-z0-9]*)(=\")([^\"]*)(\")!is", $attribute_string, $attributes) > 0)
                    {
                        foreach($attributes[0] as $key=>$row)
                        {
                            $tag['attributes'][$attributes[1][$key]] = $attributes[3][$key];
                        }
                        if(isset($tag['attributes']['template']) === true)
                        {                                             
                            $template = $this->_options['template_directory'].$tag['name'].DIRECTORY_SEPARATOR.$tag['attributes']['template'].'.html';
                            if(is_file($template) === false)
                            {                                 
//                                $tag['attributes']['template'] = false;
                                $tag['attributes']['_template'] = $template;
                            }
                            else
                            {
                                $tag['attributes']['template'] = $template;
                            }
                        }
                    }
                } 
                $tag['attributes'] = (object) $tag['attributes'];
                return $tag;
            }
        }
943988
static function stringToTags( $tags ) {

		$tags = mb_split( ',', $tags );

		foreach ( $tags as $key => &$val ) {
			$val = strip_tags( $val );
			$val = mb_convert_case( $val, MB_CASE_TITLE, 'UTF-8' );
			$val = mb_split( '\W', $val ); // Split on negated \w
			$val = implode( ' ', $val ); // Put back together with spaces
			$val = trim( $val );
			if ( ! $val ) {
				unset( $tags[ $key ] );
			}
		}

		return $tags;
	}
199318
public static function encode(String $str) : String
    {
        return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str);
    }
962946
public static function strFindAndReplaceAll($vars = array(), $str)
    {
        if (array_count_values($vars) > 0){
            foreach ($vars as $key => $val) {
                for ($i = substr_count($str, $key); $i > 0; $i--) {
                    $str = \WebCMS\Helpers\SystemHelper::strlReplace($key, $val, $str);
                }
            }
        }
        return $str;
    }
47173
def replace_simple_tags(s, from_tag='italic', to_tag='i', to_open_tag=None):
    
    if to_open_tag:
        s = s.replace('<' + from_tag + '>', to_open_tag)
    elif to_tag:
        s = s.replace('<' + from_tag + '>', '<' + to_tag + '>')
        s = s.replace('<' + from_tag + '/>', '<' + to_tag + '/>')
    else:
        s = s.replace('<' + from_tag + '>', '')
        s = s.replace('<' + from_tag + '/>', '')

    if to_tag:
        s = s.replace('</' + from_tag + '>', '</' + to_tag + '>')
    else:
        s = s.replace('</' + from_tag + '>', '')

    return s
771317
protected function sanitizeTags(array $tags)
    {
        foreach ($tags as $key => $value) {
            $tags[$key] = $this->sanitizeTag($value);
        }
        return $tags;
    }
532975
public static function stripAll($str)
	{
		return self::stripScripts(
			self::stripImages(
				self::stripTags(
					self::stripWhitespace($str)
				)
			)
		);
	}
275110
public function replaceExtraTag($tag, $value)
    {
        $this->subject = str_replace('{' . $tag . '}', $value, $this->subject);
        $this->user_subject = str_replace('{' . $tag . '}', $value, $this->user_subject);
        $this->text = str_replace('{' . $tag . '}', $value, $this->text);
        $this->user_text = str_replace('{' . $tag . '}', $value, $this->user_text);
    }
467593
public static function replaceRoman(string $str) : string
    {
        $str = self::strToArray($str);
        return implode('', self::replaceRomanArray($str));
    }
635616
public function setTags($tags, $value=null) 
    {
        if (is_array($tags))
            $this->tags = $tags;
        else if (is_string($tags))
            $this->tags[$tags] = $value;
        return $this;
    }
593956
public function set_tags_to_ignore( $tags = [ 'code', 'head', 'kbd', 'object', 'option', 'pre', 'samp', 'script', 'noscript', 'noembed', 'select', 'style', 'textarea', 'title', 'var', 'math' ] ) {
		// Ensure that we pass only lower-case tag names to XPath.
		$tags = array_filter( array_map( 'strtolower', Strings::maybe_split_parameters( $tags ) ), 'ctype_alnum' );

		$this->data['ignoreTags'] = array_unique( array_merge( $tags, array_flip( DOM::inappropriate_tags() ) ) );
	}