如何检查液体中的引号?

Dav*_*veW 5 liquid

我正在使用像“James“Jim”Smith”这样的输入字符串,其中一个人的昵称在字符串中用双引号引起来。我一直试图使用 contains 运算符来查找一个人是否有昵称,但它从未找到带双引号的条目。举个例子:

<-- Name - James "Jim" Smith -->
{% if Name contains '\"' %}
   Do Something
{% else %}
   Always gets here
{% endif %}
Run Code Online (Sandbox Code Playgroud)

如何使用 contains(或 split)在字符串中搜索文字双引号?

But*_*uts 3

你不需要逃避它。以下将返回 true:

{% assign name = 'James "Jim" Smith' %}
{% if name contains '"' %}
  true
{% else %}
  false
{% endif %}
Run Code Online (Sandbox Code Playgroud)