Hi,
I’m to write my first script in routeros.
For this script I have to find a part in a string and put it in an other variable.
I have made me a regex Filter, but I fail to convert it to the routeros regex.
This is my regex filter:
"id":"(?:\d+)","hostname":"find"
This is the string within I have to find the expression:
data={"serverrequestid":"k1x=nTjeHeSzdVh","clientrequestid":"","action":"infoDnsRecords","status":"success","statuscode":2000,"shortmessage":"DNS records found","longmessage":"DNS Records for this zone were found.","responsedata":{"dnsrecords":[{"id":"11223344","hostname":"*","type":"A","priority":"0","destination":"55.77.233.244","deleterecord":false,"state":"unknown"},{"id":"44332211","hostname":"@","type":"A","priority":"0","destination":"55.77.233.244","deleterecord":false,"state":"unknown"},{"id":"55667788","hostname":"@","type":"MX","priority":"10","destination":"mail.domain.com","deleterecord":false,"state":"unknown"},{"id":"88776655","hostname":"ftp","type":"A","priority":"0","destination":"55.77.233.244","deleterecord":false,"state":"unknown"},{"id":"99001122","hostname":"mail","type":"A","priority":"0","destination":"55.77.233.244","deleterecord":false,"state":"unknown"},{"id":"12345678","hostname":"find","type":"A","priority":"0","destination":"55.77.233.244","deleterecord":false,"state":"unknown"},{"id":"22110099","hostname":"www","type":"CNAME","priority":"0","destination":"@","deleterecord":false,"state":"unknown"}]}}
When I use the filter (on regex101.com), this is the output from the data above:
"id":"12345678","hostname":"find"
I tried to convert this to routeros regex and put it in an script, like this:
:put [:pick $DNSRecStr [:find $DNSRecStr "\"id\"\\:\"\\~(\\?\\:d\\+\\)\"\\,\"hostname\"\\:\"find\""]] ;
But it doesn’t work, so I think I have an error in this.