# advanced varibles and string operations

**URL:** <https://forum.ansible.com/t/advanced-varibles-and-string-operations/11719>\
**Category:** Ansible Project\
**Created:** [July 25, 2012, 4:59am UTC](https://forum.ansible.com/t/advanced-varibles-and-string-operations/11719 "2012-07-25T04:59:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derek\_Carter](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@Derek\_Carter](https://forum.ansible.com/u/Derek_Carter)\
**Post date:** [July 25, 2012, 4:59am UTC](https://forum.ansible.com/t/advanced-varibles-and-string-operations/11719/1 "2012-07-25T04:59:25Z")

</div>

Why is it that this variable assignment works:

is\_cent5: “‘$ansible\_distribution’ == ‘CentOS’ and ‘$ansible\_distribution\_version’.startswith(‘5’)”

But this one does not:

inventory\_host: “‘$inventory\_hostname’.split(‘.’)[0]”

What’s the difference?

I’ve tried every different incantation of the second line I can think of but the output always ends up with the ‘split(’.‘)[0]’ crap in it instead of being referenced properly.
