Skip to content

Commit be684db

Browse files
substring extraction behaviour
1 parent 6f785d3 commit be684db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

articles/frontdoor/rule-set-server-variables.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ When you work with Rule Set actions, specify server variables by using the follo
5353
* Offsets and lengths within range: `{var:0:5}` = `AppId`, `{var:7:7}` = `1f59297`, `{var:7:-7}` = `1f592979c584d0f9d679db3e`
5454
* Zero lengths: `{var:0:0}` = null, `{var:4:0}` = null
5555
* Offsets within range and lengths out of range: `{var:0:100}` = `AppId=01f592979c584d0f9d679db3e66a3e5e`, `{var:5:100}` = `=01f592979c584d0f9d679db3e66a3e5e`, `{var:0:-48}` = null, `{var:4:-48}` = null
56+
* To experiment with how {variable:offset:length} works, open a Linux bash terminal or use bash terminal in [Azure Cloud Shell](https://shell.azure.com/). Enter the following example into the terminal and examine the output to understand how the substring extraction behaves.
57+
```azurecli-interactive
58+
>>variable=helloworld123
59+
>>echo ${variable:5}
60+
world123
61+
>>echo ${variable:0:4}
62+
hell
63+
>>echo ${variable: -3:3} # In bash, space comes before negative numbers.
64+
123
65+
>>echo ${variable:5: -3}
66+
world
67+
```
68+
5669
* `{url_path:seg#}`: Allow users to capture and use the desired URL path segment in URL Redirect, URL Rewrite, or any meaningful action. User can also capture multiple segments by using the same style as substring capture `{url_path:seg1:3}`. For example, for a source pattern `/id/12345/default` and a URL rewrite Destination `/{url_path:seg1}/home`, the expected URL path after rewrite is `/12345/home`. For a multiple-segment capture, when the source pattern is `/id/12345/default/location/test`, a URL rewrite destination `/{url_path:seg1:3}/home` results in `/12345/default/location/home`. Segment capture includes the location path, so if route is `/match/*`, segment 0 will be match.
5770

5871
Offset corresponds to the index of the start segment, and length refers to how many segments to capture, including the one at index = offset.

0 commit comments

Comments
 (0)