Skip to content

[components][expression_language] Add doc for backslashes #5576

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

zerustech
Copy link
Contributor

Additional backslashes are required to escape a backslash(\)
in a string or regex because a string will be stripped by the lexer.
This should be documented here, otherwise, user may feel confused about
the unexpected behavior.

Q A
Doc fix? yes
New docs? no
Applies to ~2.4
Fixed tickets n/a

Additional backslashes are required to escape a backslash(``\``)
in a string or regex because a string will be stripped by the lexer.
This should be documented here, otherwise, user may feel confused about
the unexpected behavior.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | ~2.4
| Fixed tickets | n/a
@wouterj
Copy link
Member

wouterj commented Feb 6, 2016

Hi @zerustech! I'm very sorry for the long silence and delay with this PR. It somehow slipped under our radar.

While it looks really ugly, it is definitely needed and I agree that we should document this. However, I would like to change 2 things:

  1. Put this in a new .. caution:: box or the like

  2. Make things a bit shorter, e.g. doing something like:

    .. caution::
    
        A backslash (``\``) must be escaped by 4 backslashes(``\\\\``) in a string and
        8 backslashes(``\\\\\\\\``) in a regex. Control characters must be
        defined as the escaped form of their escape sequences.
    
        .. code-block:: php
    
            $language->evaluate('"\\\\"'); // returns \
            $language->evaluate('"a\\\\b" matches "/^a\\\\\\\\b$/"'); // returns true
            $language->evaluate('"a\\nb"'); // returns a\nb

Can you please include these changes in this PR? If you don't have time or the like, please comment and we'll take over this PR, including the changes (while keeping the credits for you of course).

@zerustech
Copy link
Contributor Author

Hi @wouterj
It's Chinese new year this week, so I might not be able to work on this PR, could you take it over? Thanks a lot.
By the way, Happy Monkey Year 2016 😄

@wouterj
Copy link
Member

wouterj commented Feb 7, 2016

In that case, have some nice days @zerustech!

I've finished this PR in #6241 So I'm going to close this one in favor of that one. Thanks again for doing the research on this and submitting the docs!

@wouterj wouterj closed this Feb 7, 2016
xabbuh added a commit that referenced this pull request Feb 7, 2016
… (zerustech, WouterJ)

This PR was merged into the 2.7 branch.

Discussion
----------

[ExpressionLanguage] Add caution about backslash handling

Finishes #5576

Original description:

 > Additional backslashes are required to escape a backslash(``\``)
 > in a string or regex because a string will be stripped by the lexer.
 > This should be documented here, otherwise, user may feel confused about
 > the unexpected behavior.
 >
 > | Q             | A
 > | ------------- | ---
 > | Doc fix?      | yes
 > | New docs?     | no
 > | Applies to    | ~2.4
 > | Fixed tickets | n/a

Commits
-------

31d74e5 Add a caution about backslash escaping
07f8e40 [components][expression_language] Add doc for backslashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants