Skip to main content

parentheses_match

Function parentheses_match 

Source
pub fn parentheses_match(
    text: &str,
    open: &str,
    close: &str,
) -> Result<Vec<ParenthesesMatch>>
Expand description

Every bracketed stretch of a string, each with those nested in it: music21’s parenthesesMatch. A bracket after a backslash is not one, and either bracket may be longer than a character.

use music21::common::stringtools::parentheses_match;

let found = parentheses_match("[not [mix] very] [well.]", "[", "]")?;
assert_eq!(found[0].text, "not [mix] very");
assert_eq!(found[0].nested[0].text, "mix");
assert_eq!((found[1].start, found[1].end), (18, 23));

§Errors

An empty bracket, or one left open or closed that was never opened.