We help IT Professionals succeed at work.

Regular Expression in Visual Studio 2008

IssacJones
IssacJones asked
on
456 Views
Last Modified: 2013-11-26
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


Comment
Watch Question

Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Top Expert 2009

Commented:
oh, I forgot the closing semi colon:

replace: $1 = rhs.$1;
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
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

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Top Expert 2009

Commented:
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;
Top Expert 2009

Commented:
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.

Author

Commented:
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.
Top Expert 2009

Commented:
aha, good news ;) (actually, not so good for me, because I will earn less points lol).
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
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!! :)
Top Expert 2009

Commented:
Don't be upset about silly things like that. I only found out by experimenting myself. Often, obvious things are only obvious once discovered ;-)
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Yeah. I'm over it now (patching the hole in the wall) ;)

j/k
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.