Replace MULTIPLE texts in a SINGLE file?????

Find, replace, find in files, replace in files, regular expressions

Replace MULTIPLE texts in a SINGLE file?????

Postby jasgot » Fri Dec 21, 2012 5:10 pm

I have a text file that will have each of the codes in the left column, once, somewhere in the file. I want to replace the left code with the right code.

ie; Replace 120106 with 130104

I need to perform the replace for each pair below, I don't want to deal with the Replace GUI window 52 times. Is there a way to do each of the following replacements in one fell swoop?

Thanks.


120106 130104
120113 130111
120120 130118
120127 130125
120203 130201
120210 130208
120217 130215
120224 130222
120302 130301
120309 130308
120316 130315
120323 130322
120330 130329
120406 130405
120413 130412
120420 130419
120427 130426
120504 130503
120511 130510
120518 130517
120525 130524
120601 130531
120608 130607
120615 130614
120622 130621
120629 130628
120706 130705
120713 130712
120720 130719
120727 130726
120803 130802
120810 130809
120817 130816
120824 130823
120831 130830
120907 130906
120914 130913
120921 130920
120928 130927
121005 131004
121012 131011
121019 131018
121026 131025
121102 131101
121109 131108
121116 131115
121123 131122
121130 131129
121207 131206
121214 131213
121221 131220
121228 131227


Jason
jasgot
Newbie
 
Posts: 2
Joined: Fri Apr 09, 2010 7:58 am

Re: Replace MULTIPLE texts in a SINGLE file?????

Postby min2max » Fri Dec 21, 2012 10:57 pm

Search and replace with regular expressions.

Assuming we are using the Perl convention of Regex.

Find - "^\d{6}([ \t]+)(\d{6})$"
Replace - "\2\1\2"

For basics of tagged regular expressions, see here:
http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/tagged_expressions.html
min2max
Basic User
Basic User
 
Posts: 18
Joined: Mon Dec 10, 2012 5:41 am

Re: Replace MULTIPLE texts in a SINGLE file?????

Postby spaceBAR » Fri Jan 04, 2013 3:48 pm

Try this,
In the "Find What window" put:
Code: Select all
(\d{6}) (\d{6})

In the "Replace With window" put:
Code: Select all
\2 \2

Also make sure and use the 'Perl' regular expressions engine
User avatar
spaceBAR
Basic User
Basic User
 
Posts: 20
Joined: Tue Oct 19, 2004 11:00 pm


Return to Find/Replace/Regular Expressions