{"__v":0,"_id":"55fc9b7b3c21291900e7e0e9","category":{"__v":1,"_id":"55fc9b7a3c21291900e7e0de","pages":["55fc9b7b3c21291900e7e0e8","55fc9b7b3c21291900e7e0e9","55fc9b7b3c21291900e7e0ea","55fc9b7b3c21291900e7e0eb","55fc9b7b3c21291900e7e0ec"],"project":"5553d36165e8260d0024419a","version":"55fc9b793c21291900e7e0d7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-14T20:15:44.034Z","from_sync":false,"order":6,"slug":"conditions","title":"Conditions"},"parentDoc":null,"project":"5553d36165e8260d0024419a","user":"5553d33065e8260d00244199","version":{"__v":12,"_id":"55fc9b793c21291900e7e0d7","project":"5553d36165e8260d0024419a","createdAt":"2015-09-18T23:17:13.545Z","releaseDate":"2015-09-18T23:17:13.545Z","categories":["55fc9b7a3c21291900e7e0d8","55fc9b7a3c21291900e7e0d9","55fc9b7a3c21291900e7e0da","55fc9b7a3c21291900e7e0db","55fc9b7a3c21291900e7e0dc","55fc9b7a3c21291900e7e0dd","55fc9b7a3c21291900e7e0de","55fc9b7a3c21291900e7e0df","55fc9b7a3c21291900e7e0e0","55fc9b7a3c21291900e7e0e1","55fc9b7a3c21291900e7e0e2","55fc9b7a3c21291900e7e0e3","55fc9bad4c80910d00b9bece","56394a0c3539050d00082122","56394a2f68b11f0d0048c9ff","56394a462fc5520d001a4db3","56394a4c2fc5520d001a4db4","56394a5b049e420d00476b5c","56394a6a2fc5520d001a4db5","56394f791593e4190073a44b","567b3adfb56bac0d0019d8d9","569d590e5a2b060d008741eb","569ea93dffccd10d00a05c7f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-15T21:11:08.005Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"If you need to extract part of a returned value, you may take advantage of some filters that you can apply to a variable path using the the | operator.\n\n\nFilters include:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Variable\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"int\",\n    \"0-1\": \"Convert value to an integer\",\n    \"1-0\": \"length\",\n    \"1-1\": \"returns the length of a string\",\n    \"2-0\": \"lower\",\n    \"2-1\": \"converts a value to lowercase\",\n    \"3-0\": \"reverse\",\n    \"3-1\": \"reverses a string\",\n    \"4-0\": \"round(precision=0,method='common')\",\n    \"h-2\": \"Parameters\",\n    \"0-2\": \"NA\",\n    \"1-2\": \"NA\",\n    \"2-2\": \"NA\",\n    \"3-2\": \"NA\",\n    \"4-1\": \"Round the number to a given precision.  \\nThe first parameter specifies the precision (default is 0), the second the rounding method.\\nIf no method is specified 'common' is used\",\n    \"4-2\": \"precision - numerical value\\ncommon - rounds either up for values of greater than or equal to 5 in the last decimal place of the number before rounding or down for values equal to less than 4\\nceiling- always rounds up\\nfloor - always rounds down\",\n    \"5-0\": \"upper\",\n    \"5-1\": \"converts a string to uppercase\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example\"\n}\n[/block]\nWith response JSON:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" {\\n    \\\"url\\\": \\\"https://www.example.com/some/path/to/something\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nand you wanted to extract the url’s path and make it uppercase, you could use:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"url|replace('https://www.example.com', '')|upper\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nwhich would give you the value:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" /SOME/PATH/TO/SOMETHING\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"string-handling-in-conditions","type":"basic","title":"String Handling in Conditions"}

String Handling in Conditions


If you need to extract part of a returned value, you may take advantage of some filters that you can apply to a variable path using the the | operator. Filters include: [block:parameters] { "data": { "h-0": "Variable", "h-1": "Description", "0-0": "int", "0-1": "Convert value to an integer", "1-0": "length", "1-1": "returns the length of a string", "2-0": "lower", "2-1": "converts a value to lowercase", "3-0": "reverse", "3-1": "reverses a string", "4-0": "round(precision=0,method='common')", "h-2": "Parameters", "0-2": "NA", "1-2": "NA", "2-2": "NA", "3-2": "NA", "4-1": "Round the number to a given precision. \nThe first parameter specifies the precision (default is 0), the second the rounding method.\nIf no method is specified 'common' is used", "4-2": "precision - numerical value\ncommon - rounds either up for values of greater than or equal to 5 in the last decimal place of the number before rounding or down for values equal to less than 4\nceiling- always rounds up\nfloor - always rounds down", "5-0": "upper", "5-1": "converts a string to uppercase" }, "cols": 3, "rows": 6 } [/block] [block:api-header] { "type": "basic", "title": "Example" } [/block] With response JSON: [block:code] { "codes": [ { "code": " {\n \"url\": \"https://www.example.com/some/path/to/something\"\n}", "language": "json" } ] } [/block] and you wanted to extract the url’s path and make it uppercase, you could use: [block:code] { "codes": [ { "code": "url|replace('https://www.example.com', '')|upper", "language": "text" } ] } [/block] which would give you the value: [block:code] { "codes": [ { "code": " /SOME/PATH/TO/SOMETHING", "language": "text" } ] } [/block]