Link to home
Start Free TrialLog in
Avatar of IssacJones
IssacJones

asked on

Regular Expression in Visual Studio 2008

Hiya

I have a long list of variables which I need to add to a copy constructor e.g.

x1 = rhs.x1;
y4 = rhs.y4;
z100 = rhs.z100;
y8 = rhs.y8;

etc. (involving hundreds of variables).

Now I have another list which looks like this:

x1 = 2.34;
y4 = 8888;
z100 = 3.2;
y8 = FALSE;

etc.

I feel there must be a way to use regular expressions to convert the second list into the first.

Can anybody tell me how to do this using regular expressions in Visual Studio 2008 (MFC) i.e. from the VS editor.

Thanks

John


ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh, I forgot the closing semi colon:

replace: $1 = rhs.$1;
Avatar of kaufmed
If within the editor you mean inside the Find/Replace box, then your regex would be:
Find:
    ^{[^:b]+}.+
 
Replace:
    \1 = rhs.\1

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
lol

dollar syntax doesn't work in replace box? Ah, the whole syntax is different. Great, I always forget that. Just tested a bit with mine and yours and since most of the time the code is indented, I come up with this blended expression:

find:    ^{:b+[^:b]+}.*

replace:    \1 = rhs.\1;
tx for the grade but...

this seems to be the day that the splitting points button is not found by the askers.. you are the fourth already. Are you aware of the possibility to split points if more experts have worked towards a solution?

If you still want to do that, please use the Request Attention button to ask for reopening of the question and once a moderator has done so (can take a few hours) you can reassign the split points.
Avatar of IssacJones
IssacJones

ASKER

hi abel, kaufmed

you prememted an email to experts exchange. I had indeed wanted to split the points but something strange happened during the allocation (which wasn't helped by my screen freezing and having to re-boot). I will attempt to split the points again.
aha, good news ;) (actually, not so good for me, because I will earn less points lol).
abel...  I must say: You are a gentleman, sir. In any event, I was upset at myself for forgetting that the lines in the editor had leading space!! :)
Don't be upset about silly things like that. I only found out by experimenting myself. Often, obvious things are only obvious once discovered ;-)
Yeah. I'm over it now (patching the hole in the wall) ;)

j/k