# match() documentation bug?

**URL:** <https://forum.ansible.com/t/match-documentation-bug/17623>\
**Category:** Ansible Project\
**Created:** [February 25, 2015, 7:09pm UTC](https://forum.ansible.com/t/match-documentation-bug/17623 "2015-02-25T19:09:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [February 25, 2015, 7:09pm UTC](https://forum.ansible.com/t/match-documentation-bug/17623/1 "2015-02-25T19:09:07Z")

</div>

Hi,

I'd say the documentation [1] for match() is not entirely clear:

"‘match’ will require a complete match in the string, while ‘search’  
will require a match inside of the string."

after reading this I wouldn't expect that  
abc\>match("a") is true.

I run this on ansible 1.8.2:

&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;input: abc  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;- shell: msg="abc matches a?"  
&nbsp;&nbsp;&nbsp;&nbsp;when: input|match("a")

&nbsp;&nbsp;- shell: msg="abc matches ^a$?"  
&nbsp;&nbsp;&nbsp;&nbsp;when: input|match("^a$")

&nbsp;&nbsp;- shell: msg="abc matches b?"  
&nbsp;&nbsp;&nbsp;&nbsp;when: input|match("b")

A better wording of the current behaviour would be:

"‘match’ will require a complete match at the beginning of the string"

[1] [http://docs.ansible.com/playbooks\_variables.html](http://docs.ansible.com/playbooks_variables.html)

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [February 26, 2015, 5:38am UTC](https://forum.ansible.com/t/match-documentation-bug/17623/2 "2015-02-26T05:38:52Z")

</div>

>
