Add or replace MAC address delimiters/separators.

@param string $str       The MAC address
@param string $separator The delimiter

@return string The MAC addres with delimiter/separator [':','-']
559995
public function addMacAddressSeparator(string $str, string $separator = ':'): string
    {
        return join($separator, str_split(preg_replace('/[^a-f0-9]/i', '', $str), 2));
    }
32399
public function add($str)
    {
        $i = count($this->values);
        $this->values[$i] = $str;
        return $i;
    }
550531
public function substringBeforeLast($separator)
    {
        if (($offset = $this->indexOfLast($separator)) === false) {
            return false;
        }

        return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
    }
346350
private function splitData(string &$str)
    {
        if ($str === '') {
            return $str;
        }

        $replace = function (&$string) {

            if (\strpos($string, $this->symbUnescapedRel) !== false) {
                $string = \preg_replace(
                    self::$DELIMITER . $this->symbRel . "(?=" . $this->symbRel . ")|" . $this->symbRel . "(?=" . $this->sepData . ")|" . $this->symbRel . "(?=" . $this->sepComp . ")|" . $this->symbRel . "(?=" . $this->symbEnd . ")" . self::$DELIMITER,
                    '',
                    $string
                );
            }

            return \str_replace(
                $this->stringSafe,
                $this->symbUnescapedRel,
                $string
            );
        };

        // check for "sepUnescapedComp" in the string
        if (\strpos($str, $this->sepUnescapedComp) === false) {
            return $replace($str);
        }

        // split on "sepComp" if not escaped (negative lookbehind)
        $array = \preg_split(
            self::$DELIMITER . "(?<!" . $this->symbRel . ")" . $this->sepComp . self::$DELIMITER,
            $str
        );
        // fallback
        if ($array === false) {
            $array = [[]];
        }

        if (\count($array) === 1) {
            return $replace($str);
        }

        foreach ($array as &$value) {
            $value = $replace($value);
        }

        return $array;
    }
1100764
private function pathSplit($str)
    {
        // FIXME: May not work on Windows

        $set = array();

        $str = str_replace("/./", "/", $str);

        if ($str[0] != "/") {
            $str = dirname($_SERVER["SCRIPT_FILENAME"]) . "/" . $str;
        }

        while (strlen($str) > 1 && $str != "/") {
            $set[] = basename($str);
            $str   = dirname($str);
        }

        if ($str != "/") {
            $set[] = $str;
        }

        return $set;
    }
1075713
public static function slug(string $string, string $separator = '.'): string
    {
        // Make sure standard characters has been replaced to separator.
        $slug = str_replace(['-', '_', ' ', '.'], $separator, mb_strtolower($string));

        // Remove all "funny" characters.
        $slug = preg_replace('/[^a-z0-9' . preg_quote($separator) . ']/', '', $slug);

        return $slug;
    }
755104
public static String mkString(@javax.annotation.Nonnull final String separator, final String... strs) {
    return Arrays.asList(strs).stream().collect(Collectors.joining(separator));
  }
620447
public function setSeparator(string $separator = "F") : CNabuDataObject
    {
        if ($separator === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$separator")
            );
        }
        $this->setValue('nb_site_map_separator', $separator);
        
        return $this;
    }
330190
public static function incrementSeparated(string $string, string $separator = '-'): string
    {
        if (preg_match('/' . $separator . '(\d+)$/', $string, $matches)) {
            $string = self::stripRight($string, $separator . $matches[1]);
            $duplicateNo = ((int) $matches[1]) + 1;
        } else {
            $duplicateNo = 2;
        }

        $newString = $string . $separator . $duplicateNo;

        return $newString;
    }
395265
public Map<String,String> parse(final String str, char separator) {
		if (str == null) {
			return new HashMap<String,String>();
		}
		return parse(str.toCharArray(), separator);
	}
932221
public static function mechanize($str, $separator = '_')
    {
        $out = strtolower($str);
        $out = self::transliterate($out);
        $out = preg_replace(
            array('/[\'’]/', '/[^a-zA-Z0-9\s_]/', '/[\s_]+/', '/^_|_$/'),
            array('', '_', '_', ''),
            $out
        );
        if ($separator !== '_') {
            $out = str_replace('_', $separator, $out);
        }
        return $out;
    }
1144073
public static function removeFirst(string $string, string $separator): string
    {
        $string = explode($separator, $string);
        $string = Arr::removeFirst($string);
        return implode($separator, $string);
    }
1007308
public function substringAfterLast($separator)
    {
        if (($offset = $this->indexOfLast($separator)) === false) {
            return false;
        }

        return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
    }
467593
public static function replaceRoman(string $str) : string
    {
        $str = self::strToArray($str);
        return implode('', self::replaceRomanArray($str));
    }
149570
static function strReplace($str,$params)
    {
        foreach ($params as $k=>$v) {
            $str = str_replace($k, $v, $str);
        }
        return $str;
    }
1362306
private function ipAddressCalculation($format, $separator = '')
    {
        return implode($separator, array_map(
            function ($quad) use ($format) {
                return sprintf($format, $quad);
            },
            $this->quads
        ));
    }
1338972
public static function slug(string $str, string $delimiter = '-') : string
    {
        $str = static::toAscii($str);

        // Remove all characters that are neither alphanumeric, nor the separator nor a whitespace.
        $str = preg_replace('![^'.preg_quote($delimiter).'\pL\pN\s]+!u', '', mb_strtolower($str));

        // Standardize the separator.
        $flip = $delimiter == '-' ? '_' : '-';
        $str = preg_replace('!['.preg_quote($flip).']+!u', $delimiter, $str);

        // Replace all separator characters and whitespace by a single separator.
        $str = preg_replace('!['.preg_quote($delimiter).'\s]+!u', $delimiter, $str);

        return trim($str, $delimiter);
    }