Massive apply

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Chadi
Posts: 7
Joined: Sat Feb 25, 2006 10:33 pm

Massive apply

Post by Chadi »

How do I do a massive apply by adding

";

after the end of each line that looks like this (but ending in various numbers)

$server = "https://111.202.69.5

Thank you.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: ^\$server = "https://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$
Replace with: \0";

[X] Regular expression
Chadi
Posts: 7
Joined: Sat Feb 25, 2006 10:33 pm

Post by Chadi »

Thanks.

What about adding <br /> after each and every line, ending in various characters?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Match the end of line and insert <br /> there:
Find what: $
Replace with: <br />

[X] Regular expression
Chadi
Posts: 7
Joined: Sat Feb 25, 2006 10:33 pm

Post by Chadi »

Where can I find how to do these things?

I need to do this. I have a list of "badwords" filter

I need to add } after each word and { before each word

So,

{badword}
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

There is no general mechanism in TextPad to use a list of words in this way, but if the list is not too long you can do this:
Find what: \<(badword1|badword2|badword3|...)\>
Replace with: {\0}

[X] Regular expression
(Make sure the list ends with the last bad word, not with a |.)
This assumes you are using Posix regular expression syntax:
Configuration | Preferences | Editor

[X] Use POsix regular expression syntax
There are many regular expression tutorials on the net.

If you want to get more deeply into them, a standard reference in general is

Friedl, Jeffrey E F
Mastering Regular Expressions, 2nd ed
O'Reilly, 2002
ISBN: 0596002890
http://regex.info/

But be aware that TextPad's regular expression recogniser is rather weak by the current standards of these things. The one WildEdit (http://www.textpad.com/products/wildedit/) uses is much better.
Chadi
Posts: 7
Joined: Sat Feb 25, 2006 10:33 pm

Post by Chadi »

Thank you.

I should have clarified that each badword is one per line

badword1
badword2
etc...
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I guessed that. But if the list isn't too long, you can easily convert it into a usable form. (Replace \n by |, etc.)

You might like to try WildEdit and investigate its Newline separates alternatives option.
Post Reply