Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Router] added \Z as regex end for route requirement#37714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@zlodes
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PRsymfony/symfony-docs#...

In previous PR (#37711) I added/A and/z, but$ in regex is/z +/Z.

Thanks@rvitaliy:#37711 (comment)

References:
^ and $:https://www.pcre.org/original/doc/html/pcrepattern.html#TOC1
\A, \z, \Z:https://www.pcre.org/original/doc/html/pcrepattern.html#SEC5

The \A, \Z, and \z assertions differ from the traditional circumflex and dollar (described in the next section) in that they only ever match at the very start and end of the subject string, whatever options are set. Thus, they are independent of multiline mode. These three assertions are not affected by the PCRE_NOTBOL or PCRE_NOTEOL options, which affect only the behaviour of the circumflex and dollar metacharacters. However, if the startoffset argument of pcre_exec() is non-zero, indicating that matching is to start at a point other than the beginning of the subject, \A can never match. The difference between \Z and \z is that \Z matches before a newline at the end of the string as well as at the very end, whereas \z matches only at the end.

@nicolas-grekas
Copy link
Member

This looks like unneeded precaution to me. New lines are not legit in URLs.

zlodes reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to thenext milestoneAug 1, 2020

if ('$' ===substr($regex, -1)) {
$regex =substr($regex,0, -1);
}elseif (\strlen($regex) -2 ===strpos($regex,'\\z')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unrelated to the PR: couldn't this be written as this?
} elseif (false !== strpos($regex, '\\z', -2)) {

Copy link
ContributorAuthor

@zlodeszlodesAug 3, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@nicolas-grekas triedstrpos andstrrpos:

strpos(): Offset not contained in string in .... (strpos doesn't accept negative offset)
strrpos(): Offset is greater than the length of haystack string

nicolas-grekas reacted with thumbs up emoji
@zlodes
Copy link
ContributorAuthor

#37714 (comment) ⬆️

@zlodeszlodes closed thisAug 3, 2020
@zlodeszlodes deleted the route-requirements-add-regex-Z branchAugust 3, 2020 09:43
@nicolas-grekasnicolas-grekas modified the milestones:next,5.2Oct 5, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

5.2

Development

Successfully merging this pull request may close these issues.

3 participants

@zlodes@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp