How to replace something with nothing (deleting)?

A place to try and solve your RegEx problems.
Post Reply
User avatar
Maxtur

How to replace something with nothing (deleting)?

Post by Maxtur »

Hello,

I've realized that when you replace something with blank, meaning deleting it, it won't replace it with blank.It actually puts a new line there which is invisible in notepad but when you move your cursor you will see it.

example:
Make a notepad file:

aaaa
bbbb
cccc

Now replace "bbbb" with "" result:

aaaa
cccc

Now click your cursor at the end of "aaaa". One click on the right arrow should move to "bbbb".But you have to click twice the --> arrow to go there because there is an invisible line there right after "aaaa".

Second proof:

Using Text Crawler,search for (using regex):
aaaa
cccc

You will find nothing. Because there is a hidden line there :( You have to search for:
aaaa

cccc

Question: How can we actually delete something?
User avatar
Fool4UAnyway

Re: How to replace something with nothing (deleting)?

Post by Fool4UAnyway »

When you search for "bbbb" and replace it by {blank}, that is what actually happens.

If you want the empty line that remains, to be removed (as well), you will have to include the newline character(s), which may be \r, \n or \r\n.

Find:
bbbb\r\n

Replace by:
{blank}

This should work for your example.
Post Reply