Home > Blockchain >  Regex remove whole block whoch contain this words
Regex remove whole block whoch contain this words

Time:07-06

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 which contains mrzulf I have to replace it with blank.

CodePudding user response:

There is no - in the example strings, and not all the examples end on a digit before the curly like in this part of the pattern [0-9] \s\{

You can match:

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

And replace with an empty string.

Regex demo

If there should be a space and word characters before the opening { then, and if you do not want to match newlines before the opening {:

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

Regex demo

  • Related