Forum Discussion
Robert_47833
Altostratus
Jun 04, 2012use string command to match many digitals
hello,dear
my url is
http://www.cjj.com/sit/event/12312343214324/313131/temp
I 'd like to use string command to filter all non-digital uri
![string match {^/sit/event/[0-9]*/[0-9]*/*} [HTTP::uri] ]
right?
* here only can represent digital when it is put after [0-9],right?
8 Replies
- Robert_47833
Altostratus
besides thi ,"string is interge" and "string is digit"
what is the difference bewtween them - hoolio
Cirrostratus
Hi Jucao,
string match doesn't accept regex syntax like anchors (^) or a repeat count for a character class (*). See this TCL wiki page for details on string is integer and is digit:
http://wiki.tcl.tk/10166
What do you mean by "filter all non-digital URIs)? Do you want to match any URI which starts with /sit/event that doesn't have two directories of numbers? Do you want to remove the numbers? Or do something else?
Aaron - Robert_47833
Altostratus
hello.,Aaron
glad to see your reply
sorry for my bad question
actually what I want to achieve is:
I need to check whether one pattern is number(s) or not
for example:
/cjj/xx/123456/xx
/cjj/xx/23tz/xx
the first /cjj/xx/123456/xx is what I want because I need to do some action to this 123456
23tz is not I want,I need pure number in that palce
string is
digit or interger?
I don't know the difference between them
the number what I mean is 0-9 .0-9 is number I mean
which command should I use ? digit or interger? - Joel_Moses
Nimbostratus
"string is digit" can include characters outside of the standard [0-9] in unicode if they are meant to represent numbers in other languages.
"string is integer" allows only numbers that can be recognized by the system as valid integers, with a couple of restrictions. From memory (and don't take my word on this, test it for yourself):
1) It'll see negative signed numbers as integers, so if you send it "-341343" and "454255" it'll say both are integers, which they are. But it's a case you probably want to check for if you think you may see a dash in that URI field.
2) It'll only see numbers that fit into a machine word, so you're limited to checking for numbers lower than 10000000000.
3) It will see integers in C-style 0x notation, so if your string begins with "0x" you may need to check for this.
But I don't think I'd use either for what you're doing. In the other thread, I explained about the use of "getfield". I'd use that syntax, and then do a [string match [0-9] $value_from_getfield] to test for whether it's all digits or not. - Robert_47833
Altostratus
hello,Joel
thanks for your reply
[string match [0-9] $value_from_getfield] seems a good method
but I have one question, if $value_from_getfield is 999xxyz ,what is the result of [string match [0-9] $value_from_getfield]? - Joel_Moses
Nimbostratus
If the string is all digits, then the above command would return 1 (True). If not, it'd return 0 (False). You can use it like so:set captured_value [getfield [HTTP::uri] "/" 4] if { [string match [0-9] $captured_value] } { log local0. "The URL path entry $captured_value is okay (all digits)." } else { log local0. "The URL path entry $captured_value is not okay (non-digit characters were found)." }
Replace the log sections with your logic to do what you need with that part of the URI. Hope this helps! - Robert_47833
Altostratus
oh,ok
but string match A B means B contains A
for example
B = 99xyz
A = 9
B still contains A,but B is not all digits - hoolio
Cirrostratus
Replied here:
https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/2158816/showtab/groupforums/Default.aspx
Aaron
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