# regex\_replace returning '\\u0001'

**URL:** <https://forum.ansible.com/t/regex-replace-returning-u0001/16290>\
**Category:** Ansible Project\
**Created:** [September 19, 2014, 7:13pm UTC](https://forum.ansible.com/t/regex-replace-returning-u0001/16290 "2014-09-19T19:13:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [September 19, 2014, 7:13pm UTC](https://forum.ansible.com/t/regex-replace-returning-u0001/16290/1 "2014-09-19T19:13:19Z")

</div>

$ ansible-playbook --version  
ansible-playbook 1.8 (devel 1d3a8bd39c) last updated 2014/09/18 10:33:54 (GMT -400)

Hello! This is driving me bonkers . . . can anyone see what I’m doing wrong here?

Setting a var, which is fine:

- name: Get VBox version for installing extension pack  
command: /usr/bin/VBoxManage --version  
register: vbox\_ver

TASK: [workstation | debug msg={{ vbox\_ver.stdout }}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “4.3.10\_Ubuntur93012”  
}

Then trying to set a fact based on that using regex\_replace:

- name: Set major/minor number of vbox release  
set\_fact:  
vbox\_ver\_maj: “{{ vbox\_ver.stdout | regex\_replace(‘^(._)\_._$’,‘\1’) }}”

which gives me:

TASK: [workstation | debug msg={{ vbox\_ver\_maj }}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “\u0001”  
}

when it should give me 4.3.10 . … any thoughts would be greatly appreciated!

Regards,  
Guy

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 19, 2014, 7:52pm UTC](https://forum.ansible.com/t/regex-replace-returning-u0001/16290/2 "2014-09-19T19:52:33Z")

</div>

This happens when you do not have enough slashes. There are a different number of slashes needed for escape based on if you are using complex args (YAML) as opposed to args (key=value)

complex args: \\  
args: \

So you need to increase your slashes to a total of 4

---

<div class="post-metadata">

**Author:** ![Guy\_Matz](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Guy\_Matz](https://forum.ansible.com/u/Guy_Matz)\
**Post date:** [September 19, 2014, 8:19pm UTC](https://forum.ansible.com/t/regex-replace-returning-u0001/16290/3 "2014-09-19T20:19:51Z")

</div>

Soooooo much better. Thank you!!
