Replace with random data

General questions about using TextPad

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

Post Reply
insolitude
Posts: 8
Joined: Tue Apr 04, 2006 12:33 am

Replace with random data

Post by insolitude »

Hi, I'm trying to insert random data using search/replace. For example:

Search for: .
Replace with: ,[random data].

Before: some text.
After: some text,whatever.

Technically the data doesn't need to be random. It can use characters from the same line. For example:

Search for: .
Replace with: ,[random data].

Before: some text.
After: some text,text.

Any ideas? TIA!
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Does this give you some ideas?
Find what: ([^.,]{1,20})\.
Replace with: \1,\1

[X] Regular expression

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

[X] Use POSIX regular expression syntax
insolitude
Posts: 8
Joined: Tue Apr 04, 2006 12:33 am

Post by insolitude »

Yes, that is great. Possible to replace with a letter instead of a word?

Before: Some Texts.
After: Some Texts,T.

OR

Before: Some Texts.
After: Some Texts,s.

Meanwhile I'm going to spend some time decoding your suggestion, once I understand it I can probably answer my own question...
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

To copy the word immediately preceding the full stop:
Find what: ([a-z]+)\.
Replace with: \1,\1.
To copy the first word of the line:
Find what: ([a-z]+)(.*)\.
Replace with: \1\2,\1.
To copy the first letter of the word immediately preceding the full stop:
Find what: ([a-z])([a-z]*)\.
Replace with: \1\2,\1.
To copy the last letter of the word immediately preceding the full stop:
Find what: ([a-z])\.
Replace with: \1,\1.
These assume you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Post Reply