For instance, let's consider the following YAML data:
- key_1: '$.*?/|\^(){}+@[]&_-'
key_2:
- '$.*?/|\^(){}+@[]&_-'
- "{\_}"
- value23
key_3: value31
key_4:
- value41
- value42
key_5: value51
- key_1_: value12
_key_2:
- value24
- value25
key__3: '$.*?/|\^(){}+@[]&_-'
key_5___: value52The goal is:
- to replace all '_' from the keys into '-', except for the first character which may be a '_';
- all values must remain untouched
- the name and number of the keys are variable
- the depth of "recursiveness" is variable and unlimited
For instance here, the translation would result as:
- key-1: '$.*?/|\^(){}+@[]&_-'
key-2:
- '$.*?/|\^(){}+@[]&_-'
- "{\_}"
- value23
key-3: value31
key-4:
- value41
- value42
key-5: value51
- key-1-: value12
_key-2:
- value24
- value25
key--3: '$.*?/|\^(){}+@[]&_-'
key-5---: value52Any suggestion?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/000d7d79-ddbe-45c9-89c4-2eef73979b2f%40googlegroups.com.
"ansible_facts": {
"my_list2": [
{
"key-1": "$.*?/|\\^(){}+@[]&_-",
"key-2": [
"$.*?/|\\^(){}+@[]&_-",
"{ }",
"value23"
],
"key-3": "value31",
"key-4": [
"value41",
"value42"
],
"key-5": "value51"
},
{
"_key-2": [
"value24",
"value25"
],
"key--3": "$.*?/|\\^(){}+@[]&_-",
"key-1-": "value12",
"key-5---": "value52"
}
]
},
my_struct:
config:
key_1: '$.*?/|\^(){}+@[]&_-'
key_2:
- '$.*?/|\^(){}+@[]&_-'
- "{\_}"
- value23