Forum Discussion
String Scan question ... trying to do something really simple
- Jun 28, 2016
String matchers are "greedy", so %s will match everything up to the next whitespace. That's why
/%s/%s/%swon't work; everything ends up in$part1.The second construct should work. Indeed, on 11.5.4, I do the following:
when CLIENT_ACCEPTED { set path "/foo/bar/baz/bing" set x [scan $path {/%[^/]/%[^/]/%s} part1 part2 part3] if { $x == 3 } { log local0. "part1 = $part1; part2 = $part2; part3 = $part3" } else { log local0. "scan returned ($x) elements" } }
And it works as I expect. In the logs, I get:
Jun 27 19:00:01 b201 info tmm[13446]: Rule /Common/test_scan : part1 = foo; part2 = bar; part3 = baz/bing
String matchers are "greedy", so %s will match everything up to the next whitespace. That's why /%s/%s/%s won't work; everything ends up in $part1.
The second construct should work. Indeed, on 11.5.4, I do the following:
when CLIENT_ACCEPTED {
set path "/foo/bar/baz/bing"
set x [scan $path {/%[^/]/%[^/]/%s} part1 part2 part3]
if { $x == 3 } {
log local0. "part1 = $part1; part2 = $part2; part3 = $part3"
}
else {
log local0. "scan returned ($x) elements"
}
}
And it works as I expect. In the logs, I get:
Jun 27 19:00:01 b201 info tmm[13446]: Rule /Common/test_scan : part1 = foo; part2 = bar; part3 = baz/bing
- Carl_Weiss_1340Jul 12, 2016Nimbostratus
sorry for the tardiness - I tried the alternative again and viola! it worked (not sure what happened when I tested it before).
Recent Discussions
Related Content
* 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