Skip to content

Commit

Permalink
minor twigphp#1457 Fixed the matches operator code example (brandon…
Browse files Browse the repository at this point in the history
…kelly)

This PR was merged into the 1.16-dev branch.

Discussion
----------

Fixed the `matches` operator code example

A customer just pointed out that your `matches` operator code example wasn't working for them, and it ended up being because its backslashes themselves needed to be escaped by additional backslashes. (I've verified this.)

While I was editing it, I also switched to forwardslash delimiters on the regex, since those are much more commonly used than curly brackets. (I hadn't even been aware that curly brackets are allowed.) To back that assertion up, [PHP's official preg_quote() docs](http://php.net/manual/en/function.preg-quote.php) state:

> The `/` is the most commonly used delimiter.

Commits
-------

33dcbc8 Fixed the `matches` operator code example
  • Loading branch information
fabpot committed Jul 29, 2014
2 parents 7d1577f + 33dcbc8 commit 4134169
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/templates.rst
Expand Up @@ -693,7 +693,7 @@ string:

.. code-block:: jinja
{% if phone matches '{^[\d\.]+$}' %}
{% if phone matches '/^[\\d\\.]+$/' %}
{% endif %}
Containment Operator
Expand Down

0 comments on commit 4134169

Please sign in to comment.