Forum Discussion
Robert_47833
Altostratus
Nov 22, 2011how to understand this syntax "?" in matches_regex
if {$queryString matches_regex "(?i)gsec=content"} {
other code
}
I don't know the what "?" represent in this syntax
does it mean 0 or 1 single character?
5 Replies
- Robert_47833
Altostratus
can "?" represent a null or a space?
if I wanna use use another syntax to replace this matches_regex.which one is better?
switch or start_with?
what syntax should I use?
thanks in advance - hoolio
Cirrostratus
Hi Jucao,
(?i) sets case insensitive for the rest of the match:
http://www.regular-expressions.info/tcl.html
If you want to check the query string for a parameter of gsec being set to content, you could use URI::query:
if {[string tolower [URI::query [HTTP::uri] gsec]] eq "content"}{
In general, string operations will be 5-10 times more efficient than regexes.
Aaron - Robert_47833
Altostratus
thanks,Aaron
[URI::query "?param1=val1¶m2=val2" param1]
the output is "val1"
does it mean this value need to end with "$",the value must be between "=" and "$" ,right?
I also wanna to use switch to replace this matches_regex
switch -glob [string tolower [HTTP::query]] {
*gsec=content* {
pool xxxx
}
does it make sense? - nitass
Employee
[root@ve1023:Active] config b rule myrule list rule myrule { when RULE_INIT { set test "/test?param1=val1¶m2=val2" log local0. "\[URI::query $test param1\]: [URI::query $test param1]" log local0. "\[URI::query $test param2\]: [URI::query $test param2]" switch [string tolower [URI::query $test param1]] { "val1" { log local0. "val1" } default { log local0. "default" } } } } [root@ve1023:Active] config tail /var/log/ltm 01:23:09 local/ve1023 err mcpd[23057]: 01020066:3: The requested rule (myrule) already exists in partition Common. Nov 22 01:23:09 local/tmm info tmm[24220]: Rule myrule : [URI::query /test?param1=val1¶m2=val2 param1]: val1 Nov 22 01:23:09 local/tmm info tmm[24220]: Rule myrule : [URI::query /test?param1=val1¶m2=val2 param2]: val2 Nov 22 01:23:09 local/tmm info tmm[24220]: Rule myrule : val1 - Robert_47833
Altostratus
elseif { $uri matches_regex "^/?$" } {
how to understand this "?$" ?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
