I want to extract multiple regex urls from a url. The only thing I could do was the following:
- name: Set regex pattern for github URL set_fact: pattern="^(git\@github\.com\:|https?\:\/\/github.com\/)(.*)\/([^\.]+)(\.git)?$" - name: Extract organization name set_fact: project_repo="{{ deploy_fork | regex_replace( "^(git\@github\.com\:|https?\:\/\/github.com\/)(.*)\/([^\.]+)(\.git)?$", "\\3" ) }}" when: deploy_fork | match( "{{ pattern }}" )
With this approach, I can reuse the pattern variable in match , but not on the set_fact line, where I assign the selected text to another variable. Is there a way to reuse a variable in set_fact that uses filter(s) ?
source share