matches
Test if string matches pattern
Given two String parameters input and pattern, tests whether pattern matches input at least once. pattern is a regular expression and is evaluated as a POSIX Extended Regular Expression (ERE).
To test whether pattern matches the entire input, make sure to begin and end the pattern with anchors. For example:
Boolean full_match = matches("abc123", "^a.+3$")
Note that regular expressions are written using regular WDL strings, so backslash characters need to be double-escaped. For example:
Boolean has_tab = matches("hello\tBob", "\\t")
Parameters
String: the input string to search.String: the pattern to search for.
Returns: true if pattern matches input at least once, otherwise false.
Example: test_matches_task.wdl
version 1.2
workflow test_matches {
input {
File json
}
output {
Boolean is_compressed = matches(basename(json), "\\.(gz|zip|zstd)")
Boolean is_read1 = matches(basename(json), "_R1")
}
}Example input:
{
"test_matches.json": "data/person.json"
}
Example output:
{
"test_matches.is_compressed": false,
"test_matches.is_read1": false
}