Page 1 of 1
replace line with instances of pattern found
Posted: Fri Jan 22, 2010 5:18 pm
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
Posted: Fri Jan 22, 2010 7:32 pm
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
Posted: Fri Jan 22, 2010 7:41 pm
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?
Posted: Fri Jan 22, 2010 9:09 pm
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.
Posted: Fri Jan 22, 2010 9:11 pm
by matty1stop
OK.
Thank you again