Description Usage Arguments Details Value See Also Examples
Split a chr string by capture groups according to a regular expression provided.
1 | GetCaptures(s, pat)
|
s |
chr string |
pat |
chr string containing a regular expression with at least 1 capture '(', ')' |
The string is returned as a matrix of start and stop position of substrings. These substrings are labelled by which capture group they belong to. Substrings outside a capture are labelled as 0.
Nested capturing groups do not work.
Num matrix indexing substrings of s. Each columns represents a substring. Row 1 is the label, Row 2 is the start, row 3 the stop letter of each substring. Substrings which are part of a capture are labelled with increasing numbers as they appear in s beginning with 1. Substrings which are not part of a capture are labelled with 0. If nothing was captured in chr s, NULL is returned.
Other CapturePattern module functions: CapturePatternUI
,
CapturePattern
1 2 3 4 5 | s <- ">ENSG00000139083_8_61387.34117"
pat <- "^.*(SG.+?)1.*_(.+?)_.*$"
m <- GetCaptures(s, pat)
apply(m, 2, function(x) substr(s, x[2], x[3]))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.