Forum Discussion
Robert_47833
Altostratus
Nov 22, 2011how to match 6 digtals via command except matches_regex
hi,dear irule
if {$uri matches_regex {-[0-9][0-9][0-9][0-9][0-9][0-9]}} {
pool xxx
}
I don't wanna use matches_regex any more
do u have an alternation method to achieve this?
thanks in advance.
- nitass
Employee
i'm not quite familiar with glob or regex. hope there is another which is better than this one. 🙂[root@ve1023:Active] config b rule myrule list rule myrule { when RULE_INIT { log local0. "\[string match \[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\] 123456\]: [string match \[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\] 123456]" log local0. "\[string match \[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\] abcdef\]: [string match \[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\] abcdef]" } } [root@ve1023:Active] config cat /var/log/ltm Nov 22 01:14:32 local/ve1023 err mcpd[23057]: 01020066:3: The requested rule (myrule) already exists in partition Common. Nov 22 01:14:32 local/tmm info tmm[24220]: Rule myrule : [string match [0-9][0-9][0-9][0-9][0-9][0-9] 123456]: 1 Nov 22 01:14:32 local/tmm info tmm[24220]: Rule myrule : [string match [0-9][0-9][0-9][0-9][0-9][0-9] abcdef]: 0
- Robert_47833
Altostratus
thanks ,very much - hoolio
Cirrostratus
Hi Jucao, - Robert_47833
Altostratus
hello,Aaron - Joel_Moses
Nimbostratus
Yep, getfield is great for this:set captured_value [getfield [HTTP::uri] "/" 4]
- Robert_47833
Altostratus
I WANT TO know whether [getfield [HTTP::uri] "/" 4] are number and are in range [0-9] - Joel_Moses
Nimbostratus
Check my reply in the other thread. You can use "[string match [0-9] [getfield [HTTP::uri] "/" 4]]" to do this. (Okay, that's the all in one line way to do it, but, seriously, check the other thread.) :> - hoolio
Cirrostratus
I think you'd need to list the exact number of digits that you want to match when using string match. If you use scan, you can match on any number of digits using %[0-9]:if {[scan [getfield [HTTP::uri] "/" 4] {%[0-9]} match]==1}{ Parsed all digits } else { Did not parse all digits }
- Robert_47833
Altostratus
hi,Aaron - Robert_47833
Altostratus
hi,Aaron
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