Home  >  Q&A  >  body text

Regular expression to delete the entire block containing this word

myzol \s (.*)-[0-9] \s\{[\mrzulf\](.*?)\}
The lines
here is me
you are there
my fav

gvt
hjk hlkjhf c

myzol 123gbhj {
    test
    check myself/mrzulf/.com
}

myzol 123gbhj {
    test
    check myself/mrzulf/.com
}

myzol 1fde3gbhj {
    test
    check myself/check/.com
}

myzol 12ecehj {
    test
    check myself/mrzulf/.com
}

myzol 1evehj {
    test
    check myself/check/.com
}

Here I have to remove the block containing mrzulf I have to replace it with blank.

P粉198814372P粉198814372210 days ago279

reply all(1)I'll reply

  • P粉466909449

    P粉4669094492024-02-27 11:28:50

    There are no - in the example strings, and not all examples end with a number before curling, like the pattern [0-9] \s\{

    You can match:

    \bmyzol\s [^{]*{[^{}]*\bmrzulf\b[^{}]*}

    and replace it with an empty string.

    Regular expression demonstration

    If there should be spaces and word characters before the starting {, then if you don't want to match newlines before the starting {:

    \bmyzol\h \w \h {[^{}]*\bmrzulf\b[^{}]*}

    Regular expression demonstration

    reply
    0
  • Cancelreply