計算対象リストを文字列表現に変換します。

@param	array	$calc_list			計算対象リスト
@param	array	$replace_value_list	特定文字列に対する置換用配列
@return	string	計算対象リストの文字列表現
779566
public static function ConvertCalcListToString ($calc_list, $replace_value_list = []) {
		$in_function = false;
		$result = [];
		// CNT関数中かどうか
		$is_cnt_mode = false;
		// MIN関数中かどうか
		$is_min_mode = false;
		$counter_for_cnt_mode = 0;
		// 全ての項目がブランクかどうか
		$is_all_blank = true;

		foreach ($calc_list as $calc) {
			// CNT関数中かどうか
			if ($calc == 'CNT(' && !$is_cnt_mode) {
				// カウントの場合は、ここでカウントして数値に変換する
				// そのためresultにはpushしない
				$is_cnt_mode = true;
				$in_function = true;
				$counter_for_cnt_mode = 0;
				continue;
			}

			switch ($calc) {
				case 'MIN(':
					// MIN関数中かどうか
					if (!$is_min_mode) {
						$is_min_mode = true;
					}
				case 'MAX(':
				case 'SUM(':
				case 'AVE(':
				case 'CNT(':
					$in_function = true;
					$result[] = $calc;
					continue 2;
			}

			if ($in_function && $calc == ')') {
				$in_function = false;
				$is_min_mode = false;
				if (!$is_cnt_mode) {
					array_pop($result);
					$result[] = $calc;
				} else {
					$is_cnt_mode = false;
					$result[] = $counter_for_cnt_mode;
					$counter_for_cnt_mode = 0;
				}
				continue;
			}

			$result[] = $replace_value_list[$calc] ?? $calc;

			if (!$is_cnt_mode && !$is_min_mode) {
				// カウント、最小値以外の計算式は0へ変換
				$result[] = 0;
				if ($in_function) {
					$result[] = ',';
				}
			}
		}

		return implode($result);
	}
1370732
public static function strIreplace($search, $replace, $str, $count = null, $encoding = null)
    {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (!is_array($search)) {
            $slen = strlen($search);

            if ($slen == 0) {
                return $str;
            }

            $lendif = strlen($replace) - strlen($search);
            $search = static::strtolower($search, $encoding);
            $search = preg_quote($search, '/');
            $lstr = static::strtolower($str, $encoding);
            $i = 0;
            $matched = 0;

            while (preg_match('/(.*)' . $search . '/Us', $lstr, $matches)) {
                if ($count !== null && $i === $count) {
                    break;
                }

                $mlen = strlen($matches[0]);
                $lstr = substr($lstr, $mlen);

                $str = substr_replace($str, $replace, $matched + strlen($matches[1]), $slen);
                $matched += $mlen + $lendif;
                $i++;
            }

            return $str;
        } else {
            $keys = array_keys($search);

            foreach ($keys as $k) {
                if (is_array($replace)) {
                    if (array_key_exists($k, $replace)) {
                        $str = static::strIreplace($search[$k], $replace[$k], $str, $count, $encoding);
                    } else {
                        $str = static::strIreplace($search[$k], '', $str, $count, $encoding);
                    }
                } else {
                    $str = static::strIreplace($search[$k], $replace, $str, $count, $encoding);
                }
            }

            return $str;
        }
    }
918489
function changeSrc (childList, imgIndex, arraySrc) {
  // 由于懒加载方案是修改 src，所以在第一次加载图片的时候需要修改所有图片的 src，如若不是图片('no-src')则重定向，防止404。
  let src = arraySrc[imgIndex] !== 'no-src' ? arraySrc[imgIndex] : '?mip_img_ori=1'
  for (let i = 0; i < childList.length; i++) {
    if (childList[i].tagName === 'MIP-IMG') {
      childList[i].setAttribute('src', src)
    } else {
      let mipImg = childList[i].querySelector('mip-img')
      mipImg && mipImg.setAttribute('src', src)
    }
  }
  return childList
}
435756
public function scan($text, &$replaceList = null)
    {
        $scan_result = array();
        $text = $this->_matchCase ? $text : strtolower($text);
        $text_length = mb_strlen($text);
        for ($i = 0; $i < $text_length; $i++) {
            $word_length = $this->_check($text, $i, $text_length);
            if ($word_length > 0) {
                $word = mb_substr($text, $i, $word_length);
                $scan_result[] = $word;
                $replaceList !== null && $replaceList[] = str_repeat($this->_escapeChar, mb_strlen($word));
                $i += $word_length - 1;
            }
        }
        return $scan_result;
    }
1256834
def _formatVals(self, val_list):
        
        vals = []
        for (name, val) in val_list:
            if val is not None:
                if isinstance(val, float):
                    vals.append("%s.value %f" % (name, val))
                else:
                    vals.append("%s.value %s" % (name, val))
            else:
                vals.append("%s.value U" % (name,))
        return "\n".join(vals)
664029
def replace(input, **params):
    
    PARAM_REPLACE_LIST = 'replace'
    REPLACE_FIELD = 'field'
    REPLACE_FIND_VALUE = 'value.to_find'
    REPLACE_WITH_VALUE = 'value.replace_with'

    replace_list = params.get(PARAM_REPLACE_LIST)
    for row in input:
        for replace in replace_list:
            if row[replace[REPLACE_FIELD]] == replace[REPLACE_FIND_VALUE]:
                row[replace[REPLACE_FIELD]] = replace[REPLACE_WITH_VALUE]
    return input
352323
private String createValueFromList(List<String> valueList) {

        if (valueList == null) {
            return null;
        }
        StringBuffer result = new StringBuffer(valueList.size() * 32);
        Iterator<String> i = valueList.iterator();
        while (i.hasNext()) {
            result.append(
                replaceDelimiter(i.next().toString(), VALUE_LIST_DELIMITER, VALUE_LIST_DELIMITER_REPLACEMENT));
            if (i.hasNext()) {
                result.append(VALUE_LIST_DELIMITER);
            }
        }
        return result.toString();
    }
603423
public function value(float $value, int $decimal_points = null): string
    {
        if (is_null($decimal_points)) {
            return $value;
        }

        return $this->decimal($value, $decimal_points);
    }
140931
private static function get_wp_config_diff( $list, $previous_list, $type, $exclude_list = array() ) {
		$result = array();
		foreach ( $list as $name => $val ) {
			if ( array_key_exists( $name, $previous_list ) || in_array( $name, $exclude_list, true ) ) {
				continue;
			}
			$out          = [];
			$out['name']  = $name;
			$out['value'] = $val;
			$out['type']  = $type;
			$result[]     = $out;
		}
		return $result;
	}
438075
static function convertFilterToText( $filterDefinition, $filterData )
    {
        $replaceList = array();
        if ( $filterData['data'] )
        {
            $counter = 1;
            foreach ( $filterData['data'] as $data )
            {
                $replaceList['%' . $counter] = $data;
                ++$counter;
            }
        }
        $argumentText = $filterDefinition['text'];
        $text = eZSys::createShellArgument( $argumentText, $replaceList );
        return $text;
    }
470261
public List<String> getCellValues(String regex, List<ReplacePattern> replaces,
            boolean excludeEmptyValue) {
        List<String> valueList = new ArrayList<String>();

        if (StringUtils.isEmpty(regex)) {
            LOG.warn("列名が空であるセル値は格納できません。");
            return valueList;
        }
        Pattern pattern = Pattern.compile(regex);
        for (Entry<String, String> entry : getData().entrySet()) {
            if (pattern.matcher(entry.getKey()).matches()) {
                if (excludeEmptyValue && StringUtils.isEmpty(entry.getValue())) {
                    continue;
                }
                String value = value(entry.getValue(), replaces);
                LOG.trace("key:{}, value:{}", entry.getKey(), value);
                valueList.add(value);
            }
        }

        return valueList;
    }
637411
public function header($header, $value, $replace = true)
    {
        $this->headers[] = array($header, $value, $replace);
    }
919869
public static function createShellArgument( $argumentText, array $replaceList )
    {
        $instance = self::instance();
        $elements = $instance->splitArgumentIntoElements( $argumentText );
        $replacedElements = array();
        foreach ( $elements as $element )
        {
            if ( is_string( $element ) )
            {
                $replacedElements[] = strtr( $element, $replaceList );
                continue;
            }
            $replacedElements[] = $element;
        }
        $text = $instance->mergeArgumentElements( $replacedElements );
        return $text;
    }
280500
function processListItems(list_str) {

        listLevel++;

        list_str = list_str.replace(/\n{2,}$/,"\n");
        list_str += "~0";

        list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm, function(wholeMatch,m1,m2,m3,m4){

            var item = m4;
            var leading_line = m1;
            var leading_space = m2;

            if (leading_line || (item.search(/\n{2,}/)>-1)) {
                item = runBlockGamut(outdent(item));
            }
            else {
                item = doLists(outdent(item));
                item = item.replace(/\n$/,"");
                item = runSpanGamut(item);
            }

            return  "<li>" + item + "</li>\n";
        });

        list_str = list_str.replace(/~0/g,"");
        listLevel--;

        return list_str;
    }
168504
static public function array_as_option_list(array $data, $checkedValue=NULL, $type="select", $useTemplateString=NULL, array $repArr=NULL) {
		$typeArr = array (
			"select"	=> "selected",
			"radio"		=> "checked",
			"checkbox"	=> "checked"
		);
		
		$myType = $typeArr[$type];
		if(is_null($useTemplateString)) {
			//
			$useTemplateString = "\t\t<option value='%%value%%'%%selectedString%%>%%display%%</option>";
		}
		
		$retval = "";
		foreach($data as $value=>$display) {
			//see if it's the value that's been selected.
			$selectedString = "";
			if($value == $checkedValue || $display == $checkedValue) {
				//yep, it's selected.
				$selectedString = " ". $myType;
			}
			
			//create the string.
			$myRepArr = array(
				'value'				=> $value,
				'display'			=> $display,
				'selectedString'	=> $selectedString
			);
			if(is_array($repArr) && is_array($repArr[$value])) {
				//merge the arrays.
				$myRepArr = array_merge($repArr[$value], $myRepArr);
			}
			$addThis = ToolBox::mini_parser($useTemplateString, $myRepArr, "%%", "%%");
			$retval = ToolBox::create_list($retval, $addThis, "\n");
		}
		
		return($retval);
	}
1045584
function stringifyReplacerArr (key, value, stack, replacer) {
  var i, res
  // If the value has a toJSON method, call it to obtain a replacement value.
  if (typeof value === 'object' && value !== null && typeof value.toJSON === 'function') {
    value = value.toJSON(key)
  }

  switch (typeof value) {
    case 'object':
      if (value === null) {
        return 'null'
      }
      for (i = 0; i < stack.length; i++) {
        if (stack[i] === value) {
          return '"[Circular]"'
        }
      }
      if (Array.isArray(value)) {
        if (value.length === 0) {
          return '[]'
        }
        stack.push(value)
        res = '['
        // Use null as placeholder for non-JSON values.
        for (i = 0; i < value.length - 1; i++) {
          const tmp = stringifyReplacerArr(i, value[i], stack, replacer)
          res += tmp !== undefined ? tmp : 'null'
          res += ','
        }
        const tmp = stringifyReplacerArr(i, value[i], stack, replacer)
        res += tmp !== undefined ? tmp : 'null'
        res += ']'
        stack.pop()
        return res
      }

      if (replacer.length === 0) {
        return '{}'
      }
      stack.push(value)
      res = '{'
      var separator = ''
      for (i = 0; i < replacer.length; i++) {
        if (typeof replacer[i] === 'string' || typeof replacer[i] === 'number') {
          key = replacer[i]
          const tmp = stringifyReplacerArr(key, value[key], stack, replacer)
          if (tmp !== undefined) {
            res += `${separator}"${strEscape(key)}":${tmp}`
            separator = ','
          }
        }
      }
      res += '}'
      stack.pop()
      return res
    case 'string':
      return `"${strEscape(value)}"`
    case 'number':
      // JSON numbers must be finite. Encode non-finite numbers as null.
      return isFinite(value) ? String(value) : 'null'
    case 'boolean':
      return value === true ? 'true' : 'false'
  }
}
396566
public static function ReflectDynamicConfig ($ini_list, $allow_parameter_list, $options = []) {
		//初期化
		$config_list = [];

		//設定名確認フラグ
		$valid_exsist_key = isset($options['valid_exsist_key']) ? $options['valid_exsist_key'] : true;

		//許可する設定値のリスト
		$enable_ini_name_list = array_flip($allow_parameter_list);

		foreach ($ini_list as $name => $value) {
			if ($valid_exsist_key && !isset($enable_ini_name_list[$name])) {
				throw CoreException::RaiseSystemError('許可されていない設定名が設定されています。name:%s, value:%s', [$name, $value]);
			}
			if (is_array($value)) {
				foreach ($value as $option_name => $option_value) {
					$config_list[$name][] = [
						'name'	=> ConstUtility::ReplacePhpConstValue($option_name),
						'value'	=> static::ReflectOptions($name, ConstUtility::ReplacePhpConstValue($option_value), $options),
					];
				}
			} else {
				$config_list[$name] = static::ReflectOptions($name, ConstUtility::ReplacePhpConstValue($value), $options);
			}
		}

		return $config_list;
	}