Give the positions of (, ), [, ], \{, \} within a string.

str_locate_braces(string)

Arguments

string

A character vector

Value

A data frame with 4 columns: string_num, string, position and brace. Every extracted brace amount gets its own row in the tibble detailing the string number and string that it was extracted from, the position in its string and the brace.

See also

Other locators: str_locate_nth()

Examples

str_locate_braces(c("a{](kkj)})", "ab(]c{}"))
#>    string_num     string position brace
#> 1           1 a{](kkj)})        2     {
#> 2           1 a{](kkj)})        3     ]
#> 3           1 a{](kkj)})        4     (
#> 4           1 a{](kkj)})        8     )
#> 5           1 a{](kkj)})        9     }
#> 6           1 a{](kkj)})       10     )
#> 7           2    ab(]c{}        3     (
#> 8           2    ab(]c{}        4     ]
#> 9           2    ab(]c{}        6     {
#> 10          2    ab(]c{}        7     }