Wipe off the text after a certain keyword

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
nvedia
Posts: 4
Joined: Fri Oct 17, 2008 6:32 pm

Wipe off the text after a certain keyword

Post by nvedia »

I have a file with these lines

+ G G Dandekar Machine B 69.05 76.05 + 10.14
+ Meghmani Organics Lt B 13.00 14.30 + 10.00
+ Nagpur Power B 35.00 38.50 + 10.00
+ Geodesic Ltd B 96.35 105.90 + 9.91
+ Roselabs Industries B 10.80 11.75 + 8.80

What I want to do is that wherever I am getting " B " I want to replace the text after that(including B)
so that the final file looks like this

+ G G Dandekar Machine
+ Meghmani Organics Lt
+ Nagpur Power
+ Geodesic Ltd
+ Roselabs Industries B 10.80 11.75 + 8.80

How can this be achieved?
Thanks
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

The problem will be the last line.
It is probably easiest to copy that line to the clipboard, then do the replacement (see below), then add the line from the clipboard again.

For the replacement:

Find

Code: Select all

_B_.*
(use space where I put underscores)
Replace with nothing

(regex checked).[/code]
nvedia
Posts: 4
Joined: Fri Oct 17, 2008 6:32 pm

Post by nvedia »

Thanks
When i give that I get this
Cannot find regular expression
_B_.*
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

you saw that I wrote "(use space where I put underscores) "?
nvedia
Posts: 4
Joined: Fri Oct 17, 2008 6:32 pm

Post by nvedia »

Thanks it works :)

PS: Sorry I am feeling sleepy so overlooked it :(
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I think this takes care of the last line automatically...

Search for: _B_.*\n\+
Replace with \n\+

Again, using _ for a space character
Use Regular Expressions and POSIX syntax
Hope this was helpful.............good luck,
Bob
Post Reply