Page 1 of 1
Replace with random data
Posted: Thu Feb 12, 2009 5:56 pm
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!
Posted: Thu Feb 12, 2009 7:08 pm
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
Posted: Thu Feb 12, 2009 7:41 pm
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...
Posted: Thu Feb 12, 2009 10:28 pm
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