Abacre Home > Advanced Find and Replace Home

Regular expressions FAQ

How can I remove a line with given string?

For instance you have the following text:

aaabbb
cccccc
aaaccc
cccaaa

So how can we remove all lines containing aaa text?

Please use Batch replace operation and enable "Use regular expressions".

In Search for field put:

Search for:
aaaa.*\r\n

Replace with field should be empty.

If you want to remove all lines only starting with aaa, you need to put ^ before the expression.

Search for:
^aaaa.*\r\n

Note, that \r\n is normal sequence for return and new line. For Unix or Linux files it could be just \r or \n

See also: syntax of regular expressions, regular expression builder