Page 1 of 1

REGEX LAST CHAR

Posted: Wed Feb 15, 2023 7:12 am
by lezerogan
Hello,
I am editing a text file.
I want to find each line ending with the char dot - "."
and replace only the dot by space or delete it.
I do not want to delete dot in the middle of a line.
I have tried do replace F8 with regex
I did find the correct lines by putting .*\. in field "find what"
but could not find what string to put in field "replace with"
I need help
Thank you
Lezero Gan

Re: REGEX LAST CHAR

Posted: Wed Feb 15, 2023 11:03 am
by AmigoJack
Find:

Code: Select all

\.$
Replace with: whatever you want - either a space or nothing at all. Yes: "replace" can also be left empty.

Explanation:
  • \. = Find a literal dot. This has to be preceded by a backslash, because the dot alone in a regex has the meaning of "any character".
  • $ = At the end of the line.

Re: REGEX LAST CHAR

Posted: Wed Feb 15, 2023 11:05 am
by ben_josephs
You need to anchor the match at the end of the line by using the special regex symbol, "$":
Find what: \.$
Replace with: [space or nothing]
Edit: Snap!

Re: REGEX LAST CHAR

Posted: Thu Feb 16, 2023 10:09 am
by lezerogan
Thank you