can we fetch a regex match from a variable value

Suppose I’ve url=http://example.com:90/url and now in my ansible task I want to get the url variable by {{ url }} and then do a regex match and fetch oly the hostname i.e. example.com.
Any directions on how this can be achieved would help.

`

  • name: Debug
    debug: msg=‘facter_fqdn is {{ facter_fqdn }}’
    register: ‘debug_result’
  • name: Fail
    fail: msg=‘Sample warning when fqnd != fqdn’
    when: facter_fqdn.find == “{{ facter_fqdn }}”
  • name: Fail
    fail: msg=‘Sample warning when fqdn %like% example.com
    when: facter_fqdn.find(‘example.com’) != -1
  • name: Fail
    fail: msg=‘Sample warning when fqdn %like% localdomain’
    when: facter_fqdn.find(‘.local’) != -1

`

Thanks for the response.
The goal is to match a regular expression and then use the value matched for doing other things. Just testing whether a particular string is present or not doesn’t suffice for me.
http://example.com:90/xyz
http://dual.com.87/yjhh
My script should fetch me the host name by using a regex from any of the urls in the format specified above.

Read down of page.