Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regex: groupdict: return dict of named capture groups #64474

Closed
wants to merge 4 commits into from

Conversation

jamescassell
Copy link
Contributor

SUMMARY

Return named capture groups as a dict from the regex_search and regex_findall filters.

This makes ugly list comprehensions much simpler by allowing it to be boiled to a single regex_findall.

(an example of a complicated case: https://github.com/MindPointGroup/RHEL7-STIG/blob/d0b128cef334374257a7f85d1fcb25b0653f64e0/tasks/parse_etc_passwd.yml#L10-L28 )

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

regex_search
regex_findall

ADDITIONAL INFORMATION

@ansibot
Copy link
Contributor

ansibot commented Nov 6, 2019

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 6, 2019
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Nov 7, 2019
@bcoca
Copy link
Member

bcoca commented Nov 7, 2019

could you add tests and a changelog entry as a 'minor_change' as it would be a good feature to record?

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 15, 2019
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels May 28, 2020
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels May 28, 2020
@jimi-c jimi-c added the ci_verified Changes made in this PR are causing tests to fail. label May 28, 2020
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label May 29, 2020
@jamescassell
Copy link
Contributor Author

@bcoca I've added the tests and changelog as you requested. Would be nice to have this in for 2.10.

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels May 29, 2020
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. has_issue labels Jun 6, 2020
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. pre_azp This PR was last tested before migration to Azure Pipelines. and removed core_review In order to be merged, this PR must follow the core review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Dec 7, 2020
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Apr 30, 2021
@@ -1396,12 +1396,23 @@ To search a string with a regex, use the "regex_search" filter::
# case insensitive search in multiline mode
{{ 'foo\nBAR' | regex_search("^bar", multiline=True, ignorecase=True) }}

.. versionadded:: 2.10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamescassell Could you please change the version and rebase this PR? Thanks.

@bcoca
Copy link
Member

bcoca commented May 11, 2022

Hi!

Thank you very much for your submission to Ansible. It means a lot to us that you've taken the time to contribute.

But we do not want to overload the existing filter and think a new filter might be better fit for purpose.

However, we recommend looking into providing this functionality through Ansible Galaxy via Ansible Collections. You can find more information about collections at:

Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
The mailing list and irc are great ways to ask questions, or post if you don't think this particular issue is resolved.

See this page for a complete and up to date list of communication channels and their purposes:

Thank you once again for this and your interest in Ansible!

@bcoca bcoca closed this May 11, 2022
@ansible ansible locked and limited conversation to collaborators May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 docs This issue/PR relates to or includes documentation. feature This issue/PR relates to a feature request. has_issue needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. pre_azp This PR was last tested before migration to Azure Pipelines. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants