Forum Discussion
Rory_Hewitt_139
Jun 04, 2014Nimbostratus
Determining processing based on flags in a URL
I have a URL which will come in as
/features?features=10010001
where each '1' or '0' is a 'flag'. I need to check each flag in turn and depending on its value, XOR it with a matching flag s...
- Jun 04, 2014
that kinda works, except that the characters could potentially be 0, 1 or -
may we remove - before scanning?
% scan [string map {"-" ""} 10--01-00---01] %2d%2d%2d%2d a b c d 4 % put "$a $b $c $d" 10 1 0 1
by the way, if flag is only one digit each, can we use split?
% split [string map {"-" ""} 10--01-00---01] {} 1 0 0 1 0 0 0 1
nitass
Jun 04, 2014Employee
that kinda works, except that the characters could potentially be 0, 1 or -
may we remove - before scanning?
% scan [string map {"-" ""} 10--01-00---01] %2d%2d%2d%2d a b c d
4
% put "$a $b $c $d"
10 1 0 1
by the way, if flag is only one digit each, can we use split?
% split [string map {"-" ""} 10--01-00---01] {}
1 0 0 1 0 0 0 1
- Rory_Hewitt_139Jun 05, 2014NimbostratusNope, we need the '-' in there - it implies 'null'. Although, of course, split would work fine -I don't know why I didn't think of it - probably because I'm not a Tcl programmer :) In any event, I have this working - using substr: for {set x 0} {$x < 8} {incr x} { set flag [string index $flags $x] switch $flag { "0" {...} "1" {...} default {...} } which seems to do the job rather nicely. Thanks for the help!
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