My HTML response body includes several strings such as:
listproducts.php?cat=1
listproducts.php?cat=2
listproducts.php?cat=3
I want to replace the entire string with the string "test", but am having difficulty due to the question mark symbol in the string. I tried escaping the ? with a % as well as a \ and $ without success, e.g.:
body_filter_by_lua 'ngx.arg[1] = ngx.re.gsub(ngx.arg[1],"listproducts.php%?cat=%d", "test") ';
1. What is the proper way to escape a literal ? in a string?
2. Assuming the string "listproducts.php?cat=1" is in a variable, how can I use ngx.re.gsub to substitute the string with my "test" string?
thanks!
- G