Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add sub function to Spec #32
Conversation
Horneth
referenced
this pull request
in broadinstitute/cromwell
Mar 23, 2016
Merged
Sub engine function Closes #597 #605
scottfrazer
commented on the diff
Mar 24, 2016
| @@ -2114,6 +2115,42 @@ task example { | ||
| Supported units are KiloByte ("K", "KB"), MegaByte ("M", "MB"), GigaByte ("G", "GB"), TeraByte ("T", "TB") as well as their [binary version](https://en.wikipedia.org/wiki/Binary_prefix) "Ki" ("KiB"), "Mi" ("MiB"), "Gi" ("GiB"), "Ti" ("TiB"). | ||
| Default unit is Bytes ("B"). | ||
| + | ||
| +## String sub(String, String, String) | ||
| + | ||
| +Given 3 String parameters `input`, `pattern`, `replace`, this function will replace any occurence matching `pattern` in `input` by `replace`. | ||
| +`pattern` is expected to be a [regular expression](https://en.wikipedia.org/wiki/Regular_expression). There are different implemetations of regular expression evaluators, different sets of rules etc... This choice is left to the implementor. | ||
| + | ||
| +Example 1: | ||
| + | ||
| +```wdl | ||
| + String chocolike = "I like chocolate when it's late" |
|
|
scottfrazer
and 1 other
commented on an outdated diff
Mar 24, 2016
| @@ -86,6 +86,7 @@ | ||
| * [File write_objects(Array\[Object\])](#file-write_objectsarrayobject) | ||
| * [File write_json(mixed)](#file-write_jsonmixed) | ||
| * [File size(File, \[String\])](#float-sizefile-string) | ||
| + * [File sub(String, String, String)](#string-substring-string-string) |
scottfrazer
Contributor
|
mcovarr
and 2 others
commented on an outdated diff
Mar 24, 2016
| @@ -2114,6 +2115,42 @@ task example { | ||
| Supported units are KiloByte ("K", "KB"), MegaByte ("M", "MB"), GigaByte ("G", "GB"), TeraByte ("T", "TB") as well as their [binary version](https://en.wikipedia.org/wiki/Binary_prefix) "Ki" ("KiB"), "Mi" ("MiB"), "Gi" ("GiB"), "Ti" ("TiB"). | ||
| Default unit is Bytes ("B"). | ||
| + | ||
| +## String sub(String, String, String) | ||
| + | ||
| +Given 3 String parameters `input`, `pattern`, `replace`, this function will replace any occurence matching `pattern` in `input` by `replace`. | ||
| +`pattern` is expected to be a [regular expression](https://en.wikipedia.org/wiki/Regular_expression). There are different implemetations of regular expression evaluators, different sets of rules etc... This choice is left to the implementor. |
mcovarr
Contributor
|
mcovarr
commented on an outdated diff
Mar 24, 2016
| @@ -2114,6 +2115,42 @@ task example { | ||
| Supported units are KiloByte ("K", "KB"), MegaByte ("M", "MB"), GigaByte ("G", "GB"), TeraByte ("T", "TB") as well as their [binary version](https://en.wikipedia.org/wiki/Binary_prefix) "Ki" ("KiB"), "Mi" ("MiB"), "Gi" ("GiB"), "Ti" ("TiB"). | ||
| Default unit is Bytes ("B"). | ||
| + | ||
| +## String sub(String, String, String) | ||
| + | ||
| +Given 3 String parameters `input`, `pattern`, `replace`, this function will replace any occurence matching `pattern` in `input` by `replace`. |
|
|
mcovarr
commented on an outdated diff
Mar 24, 2016
| + | ||
| +Given 3 String parameters `input`, `pattern`, `replace`, this function will replace any occurence matching `pattern` in `input` by `replace`. | ||
| +`pattern` is expected to be a [regular expression](https://en.wikipedia.org/wiki/Regular_expression). There are different implemetations of regular expression evaluators, different sets of rules etc... This choice is left to the implementor. | ||
| + | ||
| +Example 1: | ||
| + | ||
| +```wdl | ||
| + String chocolike = "I like chocolate when it's late" | ||
| + | ||
| + String chocolove = sub(chocolike, "like", "love") # I love chocolate when it's late | ||
| + String chocoearly = sub(chocolike, "late", "early") # I like chocoearly when it's early | ||
| + String chocolate = sub(chocolike, "late$", "early") # I like chocolate when it's early | ||
| +} | ||
| +``` | ||
| + | ||
| +The sub function will also accept `input` and `replace` parameters that can be coereced to a String (eg File). This can be useful to swap the extension of a filename for example |
|
|
Horneth commentedMar 23, 2016
No description provided.