Forum Discussion
Robert_47833
Nov 22, 2011Altostratus
how 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.
- nitassEmployeei'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_47833Altostratusthanks ,very much
- hooleylistCirrostratusHi Jucao,
- Robert_47833Altostratushello,Aaron
- Joel_MosesNimbostratusYep, getfield is great for this:
set captured_value [getfield [HTTP::uri] "/" 4]
- Robert_47833AltostratusI WANT TO know whether [getfield [HTTP::uri] "/" 4] are number and are in range [0-9]
- Joel_MosesNimbostratusCheck 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.) :>
- hooleylistCirrostratusI 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_47833Altostratushi,Aaron
- Robert_47833Altostratushi,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