# regex\_search

**URL:** <https://forum.ansible.com/t/regex-search/30688>\
**Category:** Ansible Developer\
**Created:** [July 1, 2019, 6:34am UTC](https://forum.ansible.com/t/regex-search/30688 "2019-07-01T06:34:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![apple.talk](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@apple.talk](https://forum.ansible.com/u/apple.talk)\
**Post date:** [July 1, 2019, 6:34am UTC](https://forum.ansible.com/t/regex-search/30688/1 "2019-07-01T06:34:53Z")

</div>

Hi,  
when I use regex\_search in my playbook, then I get this error message:

#task [Output to file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
#fatal: [R34-N5696Q-1]: FAILED! =\> {“msg”: “Unexpected templating type error occurred on ({{ out.std  
#regex\_search(‘100’) #}}): expected string or buffer”}…ignoring

- name: “Read Sub-Config”  
nxos\_command:  
provider:  
timeout: 20  
commands:

- “{{ c }}{{ subName }}”  
register: out

- name: “Output to file”  
no\_log: false  
vars:  
outsql: “{{ out | b64encode }}”  
cCmdsql: “{{ c }}{{ subName }}”  
sqlRecord: “{{ s }}-{{ subName | regex\_replace(‘interface ‘,’’,ignorecase=True) }},{{ s }},”  
**sqlVLAN: “{{ out.stdout | regex\_search(‘100’) }}”**  
lineinfile:  
path: ‘{{ p }}’  
line: ‘{{sqlRecord}}{{ sqlVLAN }}’  
create: no  
ignore\_errors: true

When change "regex\_search(‘100’) to regex\_replace(‘100’,‘9999’), that works fine.  
sqlVLAN: “{{ out.stdout | regex\_search(‘100’) }}”  
(‘100’ ist a excample, late I will search a number with ‘\d+’)

What is my problem? Can you help me?

Klemens
