def ssam(expr, string, echo_input=True): selections = "" if expr: string, selections = call(parse(expr), string) if selections: print("".join(map(str, selections)), end="") if echo_input: print(string, end="")
def test_extract(): assert ("x", "regexp", None) == se.parse("x/regexp/") assert ("x", "string", None) == se.parse("x/string/")
def test_empty_expression(): assert None == se.parse("")
def test_escaped_backslash(): assert ("x", r"\/", None) == se.parse(r"x/\//")
def test_extract_lines_and_print_if(): assert ("x", r".*\n", ("g", "string", "p")) == se.parse(r"x/.*\n/ g/string/p")
def test_extract_and_delete(): assert ("x", "regexp", "d") == se.parse("x/regexp/d")