如何从可解析的JSON输出中解析url数据并提取数据



我正在处理一个AWX可解析查询,我从查询中得到了输出,我需要的数据是URL格式的,它是

'dn': "uni/infra/funcprof/accportgrp-xxxxxxxxxx/rtaccBaseGrp-[uni/infra/accportprof-xxxxxxxxxxxx/hports-xxxxxx-typ-range]"

我想从ansible中的上述字符串中提取'xxxx'数据。我能够在python中使用/进行拆分并获得详细信息。想知道如何在Ansible中做到这一点吗?

在名为mystring的变量中使用字符串:你可以这样做:

{{ mystring.split("/")[1] | lower }}

最新更新