Page 1 of 1

how to replace a word to end of line with a blank?

Posted: Fri Nov 06, 2009 6:41 am
by GottaRun
hi folks,

i want to replace every occurrence of 'high xxxxxx' where x is anything with nothing or a blank. there is other text before the word hight that i want to keep.

is there a website that gives examples of how to find things, and to replace stuff within TextPad?

thank you so much.

Posted: Fri Nov 06, 2009 9:44 am
by ben_josephs
Find what: high .*
Replace with: high

[X] Regular expression

Replace All
Dot (.) matches any single character (except newline). Star (*) is an operator: X* matches any number (possibly zero) of Xs. So .* matches zero or more characters. It matches greedily, that is, it matches as much as possible. So, in this case, it matches to the end of the line.

To help maintain your sanity (although it makes no difference in this case) use Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.

A standard reference for regular expressions 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.

And, of course, there is TextPad's own (rather brief) help, under
Reference Information | Regular Expressions,
Reference Information | Replacement Expressions and
How to... | Find and Replace Text | Use Regular Expressions.

Posted: Fri Nov 27, 2009 7:12 am
by GottaRun
thank you.