# find module regex on destination of a link?

**URL:** <https://forum.ansible.com/t/find-module-regex-on-destination-of-a-link/25507>\
**Category:** Ansible Project\
**Created:** [September 18, 2017, 7:38am UTC](https://forum.ansible.com/t/find-module-regex-on-destination-of-a-link/25507 "2017-09-18T07:38:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goetz\_Leupold](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@Goetz\_Leupold](https://forum.ansible.com/u/Goetz_Leupold)\
**Post date:** [September 18, 2017, 7:38am UTC](https://forum.ansible.com/t/find-module-regex-on-destination-of-a-link/25507/1 "2017-09-18T07:38:18Z")

</div>

Hello,

got the following contents in a dir(/usr/java):  
#lrwxrwxrwx 1 root root 16 Jul 4 2016 default → /usr/java/latest  
#drwxr-xr-x 8 root root 4096 Mar 17 2017 jdk1.8.0\_121  
#drwxr-xr-x 8 root root 4096 Jul 12 13:41 jdk1.8.0\_141  
#drwxr-xr-x 8 root root 4096 Apr 1 2016 jdk1.8.0\_92  
#lrwxrwxrwx 1 root root 22 Sep 15 14:29 latest → /usr/java/jdk1.8.0\_141

With:

- name: Find links pointing to java installations in {{ java\_install\_dir }}  
find:  
paths: “{{ java\_install\_dir }}”  
file\_type: link  
patterns: “^(default|latest).\*$”  
use\_regex: yes  
register: links  
i get 2 results. It’ fine.

With:  
…  
patterns: “^(default|latest)._jdk._$”  
…  
I get no results.  
With:  
…  
patterns: “^(default|latest).\*$”  
contains: “jdk” # yes, a dirty try checking link content  
…  
i get 2 results.

My goal is to get only one result(latest). What do i do wrong? Thank you for any suggests.
