Looking for an approach to extract the query string from the URL such that a scenario where the query string is empty or not present is also addressed. I have following but it doesn’t cover case when query string is not present in URL.
let qryStr = "b=";
let T = datatable(url: string)
[
"https://example.com/abc.htm?a=1&b=2&c=3",
"https://example.org/abc.htm?a=1&c=3&b=2",
"https://example.net/abc.htm?b=2&a=1&c=3",
"https://example.net/abc.htm?a=1&c=3",
"https://example.net/abc.htm?a=1&c=3&b="
];
T
| project url
| extend s1 = indexof(url, qryStr)
| project url, ['qryStr'], value=split(substring(url, s1 + strlen(qryStr)), "&")[0]