Removing quoted lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
textlearner
Posts: 8
Joined: Sat Sep 09, 2006 2:53 pm

Removing quoted lines

Post by textlearner »

Hi folks,

I would like to remove all text, but NOT numerical data which are in quotes.

e.g) "text_4"
becomes
_4

I'm sure its probably simple, but i dont know how to distinguish between the quotes themselves and the text within them. Obviously just putting " in the search removes the quotemarks and not the text within them.

tia

tl
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you mean that you want to find text between double quotes, and that you want to delete those quote marks and everything between them that isn't a digit or an underscore? Is there at most one contiguous string of digits and underscores in such quoted text?

If so, this might do what you want:
Find what: "[^"0-9_]*([0-9_]+)[^"0-9_]*"
Replace with: \1

[X] Regular expression
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
textlearner
Posts: 8
Joined: Sat Sep 09, 2006 2:53 pm

Post by textlearner »

Hi ben,

Thx for the feedback. This works, but some of my strings have more than one underscore in them, so i have decided it would be easier just to remove all text AND underscores between the double quotes, but im not sure how to alter your search string to do this.
Pls advise.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: "[^"0-9]*([0-9]+)[^"0-9]*"
Replace with: \1

[X] Regular expression
Post Reply