If you want to replace text from a specific character till the end in Notepad++, here is the guide for you. With Notepad++, it becomes super easy for the developers to select, edit, and replace texts with regular expressions.
Replace text from a specific character till the end in Notepad++
Let’s go through an example. Below is the text source where I want to replace text from the character |
till the end with some other text.
A is cool|30 B is cooler|26 C is coolest|28
Here is the search string to select all text from the specific character, in this case |
.

\|.*
will work perfectly and the searched character is distinct in the text string.
\|
is your search term with\
being the escape sequence.
If you want to search for a specific text along with\
, you can choose\|SomeValue
This will give the result starting with|SomeValue
in your text file..*
returns any character
So, your search criteria select all the text starting from a specific character (in this case |
) till the end of the line.
Note: This applies if you have only one instance of the character in each line. But if you have the same character present multiple times in a single line, then Notepad++ returns the text from the first encounter of the character till the end of the line.
Replace text from the last occurrence of a specific character till the end of line
Let’s have one more example. In the below source text file, I want to replace the text starting from the last occurrence of the specific character, in this example |
, to the end of the line.
A is cool|Male|30 B is cooler|Female|26 C is coolest|Male|28
For this piece of text, \|.*
will not work, as this considers the first |
character encountered.
In this case \|.*
returns the below sub-string, hence ending up replacing the below.
|Male|30 |Female|26 |Male|28
To replace the text from a character till the end, use (.+)\s*\|\s*(.+)

This regular expression splits the line into two parts at the last occurrence of the character in the input string. Once you have the sub-strings split from the input file, you can use $1
and $2
to replace the first part or the second part respectively.
Note: Remember to use the escape sequence \
if you are searching for a special character.
That’s all it takes to replace text from a specific character till the end in Notepad++. I hope you will be able to tweak the “Replace with” text and achieve whatever you want. Do share in the comments if you have any other way in Notepad++, so our fellow readers will get benefited.
Cheers!!!
Related articles:
1. How to use Column Mode Editing in Notepad++
2. Save not adding file extension in Notepad++? Steps to change the default save extension.