replace line with instances of pattern found

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
matty1stop
Posts: 5
Joined: Mon Jan 09, 2006 4:55 pm

replace line with instances of pattern found

Post by matty1stop »

I have a line of text in which exists a pattern with which I want to repalce the whole line.
The pattern is w[0-9][0-9]u99s

An example of one line is:
105 "from w03u999s w03 "+

I would like to replace the entire line with the instance of the pattern found so it should replace:
105 "from w03u999s w03 "+
With this:
w03u999s

Can anyone please help me figure this out?

Thanks,

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

Post by ben_josephs »

Find what: .*(w[0-9][0-9]u999s).*
Replace with: \1

[X] Regular expression

Replace All
(You left out a 9.)

This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
matty1stop
Posts: 5
Joined: Mon Jan 09, 2006 4:55 pm

Post by matty1stop »

Great. Thanks for your help.

Would you happen to know of a link to a good reference of the syntax of using regular expressions in textpad?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

TextPad's help on its regular expressions is rather brief. Look under
Reference Information | Regular Expressions,
Reference Information | Replacement Expressions and
How to... | Find and Replace Text | Use Regular Expressions.

There are many regular expression tutorials on the web, and you'll find recommendations for some of them if you search this forum.

A standard reference is

Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/

But be aware that the regular expression recogniser used by TextPad is very weak compared with modern tools. So you may get frustrated if you discover a handy trick that works elsewhere but doesn't work in TextPad.
matty1stop
Posts: 5
Joined: Mon Jan 09, 2006 4:55 pm

Post by matty1stop »

OK.

Thank you again
Post Reply