How to Modify this?

General questions about using TextPad

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

Post Reply
actroid
Posts: 9
Joined: Sun Feb 27, 2011 1:27 pm

How to Modify this?

Post by actroid »

Hi All...

I'm really need advice how to edit large file txt format like this :

original file:
' abolish ' => ' annul ', ' abolition ' => ' extermination ', ' abominable ' => ' monstrous '

i need to replace like this :
' abolish ' => ' abolish ', ' abolition ' => ' abolition ', ' abominable ' => ' abominable '

And then how to make the exel file like this:

column1 column2 column3
' abolish ' = > ' abolish '
' abolition ' = > ' abolition '


Thanks a lof for all help,
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: ^'([^']+)' => '[^']+', '([^']+)' => '[^']+', '([^']+)' => '[^']+'
Replace with: '\1' => '\1', '\2' => '\2', '\3' => '\3'

[X] Regular expression

Replace All
I don't understand your requirement concerning Excel files. TextPad is a text editor. Please restate what you need purely in terms of the text that you will pass to Excel.
actroid
Posts: 9
Joined: Sun Feb 27, 2011 1:27 pm

Post by actroid »

Thanks alot ben_josephs its work...but my file in one row
and the regex code only change 3 word and the other not....sorry bad in english hope you can undestand what i means...
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you mean there may be many '...' => '...' pairs on a line?

If so, try this:
Search | Replace... (<F8>):
Find what: '([^']+)' => '[^']+'
Replace with: '\1' => '\1'

[Replace the underscore with a space]

[X] Regular expression

Replace All
Do you mean you want each adjusted pair to end up on a separate line?

If so, try this on the adjusted text:
Search | Replace... (<F8>):
Find what: ,_ [Replace the underscore with a space]
Replace with: \n

[X] Regular expression

Replace All
These assume you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
actroid
Posts: 9
Joined: Sun Feb 27, 2011 1:27 pm

Post by actroid »

Find what: '([^']+)' => '[^']+'
Replace with: '\1' => '\1'
this work....i love this tool....

Now i have the data like this:
' disparity ' => ' disparity ', ' dispassionate ' => ' dispassionate ', ' dispatched ' => ' dispatched ', ' dispatcher ' => ' dispatcher '

its posible to change all in bold word ex: (p) with (q)

TQ TQ TQ
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I have no idea what you mean. Please give an example of the text as it is and the text as you'd like it.
actroid
Posts: 9
Joined: Sun Feb 27, 2011 1:27 pm

Post by actroid »

' disparity ' => ' dTsparTty ', ' dispassionate ' => ' dTspassTonate ', ' dispatched ' => ' dTspatched ', ' dispatcher ' => ' dTspatcher '

Like that:

i need to change all i (column 3) with T
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I don't understand the significance of "column 3". In what way does this not do what you want?
Find what: i
Replace with: T

Replace All
actroid
Posts: 9
Joined: Sun Feb 27, 2011 1:27 pm

Post by actroid »

' disparity ' => ' disparity '

' disparity ' === column 1
= > column 2
' disparity ' ===column 3

i only need replace i in column 3 with T (without replace i in column 1)
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Is each pair is on a separate line?

If so, you can do this in steps:

1. Move all the text in each line starting at "=>" to the right:
Find what: =>
Replace with: [Lots of spaces]=>

Replace All
2. Turn on block select mode (this requires you to be using a fixed-width font):
Configure | Block Select Mode

3. Select a block on the right that includes all of your last column but none of your first column.

4. Make the replacement within the selection:
Find what: i
Replace with: T

[X] Selected text

Replace All
5. Remove the spaces you put in earlier:
Find what: _+=> [Replace the underscore with a space]
Replace with: [Lots of spaces] _=> [Replace the underscore with a space]

[X] Regular expression

Replace All
(6. Turn off block select mode.)
actroid
Posts: 9
Joined: Sun Feb 27, 2011 1:27 pm

Post by actroid »

I read your instruction but i'm still cant change it ...when i try to change
ex: a .... all a change. All i need only ex: change a after => and before ',

the file in one row....

' abdomen ' => ' abdomen ', ' aberration ' => ' aberration '
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I wrote:Is each pair is on a separate line?

If so...
It won't work if they're not.
jannypan
Posts: 3
Joined: Thu Mar 17, 2011 2:07 am

Post by jannypan »

Do you mean you want each adjusted pair to end up on a separate line?
Post Reply