views:

76

answers:

1

Let's say I have a bunch of text like this (simplified example, but you get the idea):

INSERT stuff(a,b,c)     VALUES('1','a','1');
INSERT stuff(a,b,c)     VALUES('2','b','1');
INSERT stuff(a,b,c)     VALUES('3','c','2');
INSERT stuff(a,b,c)     VALUES('4','d','2');
INSERT stuff(a,b,c)     VALUES('5','e','3');
INSERT stuff(a,b,c)     VALUES('6','f','3');

I'm looking for a regular expression that removes the '' from around every number but leaves the number alone.

Here's the catch. You can't count on the quoted numbers being in the same position every time.

There might be cases where it actually looks like this:

INSERT stuff(a,b,c)     VALUES('6','3','f');

Something that would work with VBScript and the RegExp object would be nice.

+4  A: 

Not sure what the syntax for VBScript objects are, but a global replacement with this will work:

Regex:   '([0-9]+)'
Replace: $1
Chadwick
That does it. I didn't try that approach because I assumed that you'd need $1 for the first match, $2 for the second, etc and I couldn't see how to make that work with an arbitrary number of matches. Obviously, I was mistaken :)
Mark Biek