public static function unescapeValue($input, $delimiter = ';')
    {
        $regex = '#  (?: (\\\\ (?: \\\\ | N | n | ; | , ) )';
        if ($delimiter) {
            $regex .= ' | ('.$delimiter.')';
        }
        $regex .= ') #x';

        $matches = preg_split($regex, $input, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

        $resultArray = [];
        $result = '';

        foreach ($matches as $match) {
            switch ($match) {
                case '\\\\':
                    $result .= '\\';
                    break;
                case '\N':
                case '\n':
                    $result .= "\n";
                    break;
                case '\;':
                    $result .= ';';
                    break;
                case '\,':
                    $result .= ',';
                    break;
                case $delimiter:
                    $resultArray[] = $result;
                    $result = '';
                    break;
                default:
                    $result .= $match;
                    break;
            }
        }

        $resultArray[] = $result;

        return $delimiter ? $resultArray : $result;
    }
public static function unescapeValue($input, $delimiter = ';')
    {
        $regex = '#  (?: (\\\\ (?: \\\\ | N | n | ; | , ) )';
        if ($delimiter) {
            $regex .= ' | ('.$delimiter.')';
        }
        $regex .= ') #x';

        $matches = preg_split($regex, $input, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

        $resultArray = [];
        $result = '';

        foreach ($matches as $match) {
            switch ($match) {
                case '\\\\':
                    $result .= '\\';
                    break;
                case '\N':
                case '\n':
                    $result .= "\n";
                    break;
                case '\;':
                    $result .= ';';
                    break;
                case '\,':
                    $result .= ',';
                    break;
                case $delimiter:
                    $resultArray[] = $result;
                    $result = '';
                    break;
                default:
                    $result .= $match;
                    break;
            }
        }

        $resultArray[] = $result;

        return $delimiter ? $resultArray : $result;
    }
public static function unescapeValue ( $ input , $ delimiter = ';' ) { $ regex = '#  (?: (\\\\ (?: \\\\ | N | n | ; | , ) )' ; if ( $ delimiter ) { $ regex .= ' | (' . $ delimiter . ')' ; } $ regex .= ') #x' ; $ matches = preg_split ( $ regex , $ input , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ resultArray = [ ] ; $ result = '' ; foreach ( $ matches as $ match ) { switch ( $ match ) { case '\\\\' : $ result .= '\\' ; break ; case '\N' : case '\n' : $ result .= "\n" ; break ; case '\;' : $ result .= ';' ; break ; case '\,' : $ result .= ',' ; break ; case $ delimiter : $ resultArray [ ] = $ result ; $ result = '' ; break ; default : $ result .= $ match ; break ; } } $ resultArray [ ] = $ result ; return $ delimiter ? $ resultArray : $ result ; }
Unescapes a property value.

vCard 2.1 says:
* Semi-colons must be escaped in some property values, specifically
ADR, ORG and N.
* Semi-colons must be escaped in parameter values, because semi-colons
are also use to separate values.
* No mention of escaping backslashes with another backslash.
* newlines are not escaped either, instead QUOTED-PRINTABLE is used to
span values over more than 1 line.

vCard 3.0 says:
* (rfc2425) Backslashes, newlines (\n or \N) and comma's must be
escaped, all time time.
* Comma's are used for delimeters in multiple values
* (rfc2426) Adds to to this that the semi-colon MUST also be escaped,
as in some properties semi-colon is used for separators.
* Properties using semi-colons: N, ADR, GEO, ORG
* Both ADR and N's individual parts may be broken up further with a
comma.
* Properties using commas: NICKNAME, CATEGORIES

vCard 4.0 (rfc6350) says:
* Commas must be escaped.
* Semi-colons may be escaped, an unescaped semi-colon _may_ be a
delimiter, depending on the property.
* Backslashes must be escaped
* Newlines must be escaped as either \N or \n.
* Some compound properties may contain multiple parts themselves, so a
comma within a semi-colon delimited property may also be unescaped
to denote multiple parts _within_ the compound property.
* Text-properties using semi-colons: N, ADR, ORG, CLIENTPIDMAP.
* Text-properties using commas: NICKNAME, RELATED, CATEGORIES, PID.

Even though the spec says that commas must always be escaped, the
example for GEO in Section 6.5.2 seems to violate this.

iCalendar 2.0 (rfc5545) says:
* Commas or semi-colons may be used as delimiters, depending on the
property.
* Commas, semi-colons, backslashes, newline (\N or \n) are always
escaped, unless they are delimiters.
* Colons shall not be escaped.
* Commas can be considered the 'default delimiter' and is described as
the delimiter in cases where the order of the multiple values is
insignificant.
* Semi-colons are described as the delimiter for 'structured values'.
They are specifically used in Semi-colons are used as a delimiter in
REQUEST-STATUS, RRULE, GEO and EXRULE. EXRULE is deprecated however.

Now for the parameters

If delimiter is not set (null) this method will just return a string.
If it's a comma or a semi-colon the string will be split on those
characters, and always return an array.

@param string $input
@param string $delimiter

@return string|string[]
Unescapes a property value .