How to pass a variable to regular expression like this?
match($0, /([^ ]+) (GET|POST|PUT|DELETE) ([^?]+)[^ ]+ HTTP\/[^ ]+ \"(VAR)\" ([^ ]+) ([^ ]+) ([^ ]+)/, matches)
I am not sure what you are trying to match, but if it is something along the lines of:
GETxxxHTTPxxx"VAR"xxx
I think that you may go this way:
{
var1="(VAR)"
var="(GET|POST|PUT|DELETE)[x]+(HTTP)[x]+\"" var1 "\"[x]+"
match($0,var,dd);
for (x in dd){
print x,"-->",dd[x]
print"-"
}
}
Which with the input above, produces the following output:
0start --> 1
-
0length --> 21
-
3start --> 15
-
1start --> 1
-
2start --> 7
-
0 --> GETxxxHTTPxxx"VAR"xxx
-
1 --> GET
-
2 --> HTTP
-
3length --> 3
-
3 --> VAR
-
2length --> 4
-
1length --> 3
-
Running at ideone here