Notepad ++ need help keeping the last character in a string

I have a regex that removes everything but numbers, and I need something like this that keeps the last character and removes everything else. I tried googling it but nothing came up.

Example:

user
user

      

just

r
r

      

+3


source to share


2 answers


you can use .*([A-Za-z\d])

with replacement$1

.*([A-Za-z\d])

: .*

greedy and matches all ([A-Za-z\d])

: capture and match an alphabet or number

enter image description here Result:



e
9
e
r
r

      

For capturing special characters, use .*(\S)

where \S

means any nonspatial character

+2


source


You can just do

.*(.)

      



... and replace the match with $1

.

0


source







All Articles