Solved

Help manipulating my String

Posted on 2012-03-29
8
280 Views
Last Modified: 2012-04-03
Hello EE,

I have a string like this:

"=SUM(B1+C1+D1)"

What I need to do is each digit I need to increase by 1

so the string need to be at the end:

"=SUM(B2+C2+D2)"

another example:
"=SUM(B4+D5+H11)"

needed result:  "=SUM(B5+D6+H12)"

any idea ? (how to repert the digit then +1 on it etc..)
0
Comment
Question by:PhilippeRenaud
  • 4
  • 2
8 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 37784197
Try:

Module Module1

    Sub Main()
        Dim input As String = "=SUM(B1+C1+D1)"
        Dim result As String = System.Text.RegularExpressions.Regex.Replace(input, "\d+", AddressOf ReplacementDelegate)
    End Sub

    Function ReplacementDelegate(ByVal m As System.Text.RegularExpressions.Match) As String
        Dim converted As Integer = Convert.ToInt32(m.Value)

        Return (converted + 1).ToString()
    End Function

End Module

Open in new window

0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37784205
I would handle this by keeping the rows seperate:

int b=5;
int d=6;
int h=11;
String result;

result = print(b,d,h);

b++;
d++;
h++;

result = print(b,d,h);


string print(int b, int d, int h)
{
  return String.Format("=Sum(B{0}+D{1}+H{2}",b,d,h)
}
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 37787087
Hey kaufmed, related question :  


http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_27655660.html


how could we do both at the same time?  do you think its possible via the same Delegate maybe?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 37787095
by the way I clicked the wrong accepted answer. damn Im sorry, how can we fix this?
I went too fast
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 37787167
You can click "Request Attention", but I'm not stressed about it. It's up to you  = )
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 37787275
Yea i did it :)
0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 37800875
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now