REGEX LAST CHAR

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
lezerogan
Posts: 2
Joined: Wed Feb 15, 2023 7:02 am

REGEX LAST CHAR

Post 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
User avatar
AmigoJack
Posts: 568
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: REGEX LAST CHAR

Post 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.
Last edited by AmigoJack on Wed Feb 15, 2023 11:18 am, edited 1 time in total.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Re: REGEX LAST CHAR

Post 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!
lezerogan
Posts: 2
Joined: Wed Feb 15, 2023 7:02 am

Re: REGEX LAST CHAR

Post by lezerogan »

Thank you
Post Reply