Skip to content

Unknown modifier error on the regex for uris that have an authority part #32

@mlambley

Description

@mlambley

Sorry to hassle you again folks, but I'm running the tests on the project and am coming up against an issue with functions.php line 360.

Numerous tests are failing with the same issue, but I'm focusing on the "http://example.org:8080/" test.

I've pasted the relevant code into http://sandbox.onlinephpfunctions.com/ so that I can test it against different PHP versions. The code is:

<?php
$uri = '//example.org:8080/';
$regex = '
          %^
            //
            (?: (?<user> [^:@]+) (: (?<pass> [^@]+)) @)?
            (?<host> ( [^:/]* | \[ [^\]]+ \] ))
            (?: : (?<port> [0-9]+))?
            (?<path> / .*)?
          $%x
        ';
var_dump(preg_match($regex, $uri, $matches));
var_dump($matches);

The error I'm getting is:

<b>Warning</b>:  preg_match(): Unknown modifier '
' in <b>[...][...]</b> on line <b>12</b><br />
bool(false)
NULL

Any advice would be appreciated. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions