Forum Discussion

Robert_47833's avatar
Icon for Altostratus rankAltostratus
Nov 22, 2011

how 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

  • 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
  • Hi Jucao,



    (?i) sets case insensitive for the rest of the match:




    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.



  • thanks,Aaron


    [URI::query "?param1=val1&param2=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?



  • [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when RULE_INIT {
            set test "/test?param1=val1&param2=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&param2=val2 param1]: val1
    Nov 22 01:23:09 local/tmm info tmm[24220]: Rule myrule : [URI::query /test?param1=val1&param2=val2 param2]: val2
    Nov 22 01:23:09 local/tmm info tmm[24220]: Rule myrule : val1