I have the below sample data
sample 1
`<TargetCode key="Zip5">78216</TargetCode>`
sample 2
<adm:TargetCode key="Zip5" account="1">78216</adm:TargetCode>
I am using the below regex
*\"Zip5\"|>(?<ZipCode>.*?)\<\/.*
...but this is not extracting the one in sample 2.
Thanks in advance
Hows this?
Zip5".*?\>(?<ZIP>\d+)\<
amended to extract to "Zip"
Please try the following run anywhere code based on your sample data:
| makeresults
| eval sample="<TargetCode key=\"Zip5\">78216</TargetCode>"
| append [| makeresults
| eval sample="<adm:TargetCode key=\"Zip5\" account=\"1\">78216</adm:TargetCode>"]
| rex field=sample "key=\"Zip5\".*\>(?<Zip5>[^\<]+)\<\/"
| table sample Zip5
Your data seems to be xml. Any reason for not having KV_MODE=xml
in props.conf
or not using spath
with your raw data?
Try Zip5[^>]+>([^>]+)<
Hows this?
Zip5".*?\>(?<ZIP>\d+)\<
amended to extract to "Zip"
It worked.Thanks
Which value you want to extract and what's the field name? Please format the code/regex by selecting it and pressing Ctrl+K so that formatting is retained.
I want to extract the 78216 into field called ZIP