I have a set of lines in a string:
alksjdlaksj asdkjf
askldjfak askdjfk
ksdjfk **Bogus** alskdjfalksdj
sadkljfal skdjfkd
and need to delete the lines with ‘Bogus’ in them. I can use
Regex.Replace(result, @"^.*Bogus.*$", "", RegexOptions.Multiline);
to detect and wipeout the said line. However, it leaves a blank line. Can I use this regex statement to clear out the blank line as well?
Make your regex non-multiline… then add a linebreak at the end so that it is part of the match.
Example: