18 November, 2008

Using VS2005 IDE regular expressions for find and replace

Suppose you have redundant information such as :

, (11,12,1,5,75,1,1,'2008-10-19 00:00:00')
, (11,13,1,6,200,1,1,'2008-10-19 00:00:00')
, (11,14,1,7,50,1,1,'2008-10-19 00:00:00')
, (11,15,1,8,100,1,1,'2008-10-19 00:00:00')
, (11,16,1,9,25,1,1,'2008-10-19 00:00:00')
, (11,17,1,10,60,1,1,'2008-10-19 00:00:00')


You need to replace the first two integer fields with say 7.


Hit Ctrl + F to bring up the find and replace dialog. click on Regular expressions.


Find : [(]:z:z,:z,

Replace with : (7,

Heres a nice page about VS 2005 IDE's regular expression comparison with other regular expression 'standards':

Coding horrors take on VS IDE regular expressions


Result:
, (7,1,14,75,1,1,'2008-10-19 00:00:00')
, (7,1,15,60,1,1,'2008-10-19 00:00:00')
, (7,1,16,10,1,1,'2008-10-19 00:00:00')
, (7,1,17,25,1,1,'2008-10-19 00:00:00')
, (7,1,18,150,1,1,'2008-10-19 00:00:00')
, (7,1,19,100,1,1,'2008-10-19 00:00:00')

1 comments:

.NET Dev said...

Other Example to make List Items Quickly
http://urenjoy.blogspot.com/2008/11/add-static-itemsmore-than-100-in-list.html

Post a Comment