Expand description
§StringModification
Often, you want to modify a string before using it.
For example you may want to get a URL’s query then
-
Split it on
/and keep only the third segment. -
Remove the first character.
-
Base64 decode it using the default URL safe alphabet.
-
Split it on
,and keep only the last segment. -
Replace the URL being cleaned with that segment.
While this seems like and is a bizarre example, this exact process is used to clean the links cnn sends you in emails.
To express the above operations, we would write a StringSource::Modified as follows:
{"SetWhole": {"Modified": {
"value": {"Part": "Query"},
"modification": {"All": [
{"KeepNthSegment": {"split": "/", "index": 2}},
{"RemoveChar": 0},
"Base64Decode",
{"KeepNthSegment": {"split": ",", "index": -1}}
]}
}}}