How to remove let's say 2 last characters in each line

Find, replace, find in files, replace in files, regular expressions

How to remove let's say 2 last characters in each line

Postby marino » Fri Dec 31, 2004 10:02 am

1. Is it possible to remove some characters on end of each line
2. The same question but for replace

Thanks.
User avatar
marino
Newbie
 
Posts: 9
Joined: Fri Dec 31, 2004 12:00 am

Re: How to remove let's say 2 last characters in each line

Postby mrainey56 » Fri Dec 31, 2004 1:06 pm

Unix Regular Expression Mode Active Advanced > Configuration > Find

Search String: ^(.+)..$

Remove last two:
Replace String: \1

Replace last two (with ZZ, for example):
Replace String: \1ZZ
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: How to remove let's say 2 last characters in each line

Postby marino » Mon Jan 03, 2005 5:44 am

Thanks.

I found out that for ex. to delete 2 last characters this can be used:
..$ and replace with nothing.
One more question:
If on end of line I have numbers with different length for ex. from 1 to 4 numbers how can I delete only those numbers.
qqqqq112
wwwww2345
eeeee1
etc

Thank You
User avatar
marino
Newbie
 
Posts: 9
Joined: Fri Dec 31, 2004 12:00 am

Re: How to remove let's say 2 last characters in each line

Postby mrainey56 » Mon Jan 03, 2005 7:22 am

\d represents a digit from 0-9
$ represents the end of the line

\d$ represents a digit at the end of the line

\d+$ represents one or more consecutive digits at the end of the line


I would try:
Search: \d+$
Replace: Nothing


Unix regular expression mode
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: How to remove let's say 2 last characters in each line

Postby marino » Tue Jan 04, 2005 2:17 pm

Thank You
User avatar
marino
Newbie
 
Posts: 9
Joined: Fri Dec 31, 2004 12:00 am


Return to Find/Replace/Regular Expressions