Help manipulating my String

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..)
LVL 1
PhilippeRenaudAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
käµfm³d 👽Connect With a Mentor Commented:
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
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
PhilippeRenaudAuthor Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
PhilippeRenaudAuthor Commented:
by the way I clicked the wrong accepted answer. damn Im sorry, how can we fix this?
I went too fast
0
 
käµfm³d 👽Commented:
You can click "Request Attention", but I'm not stressed about it. It's up to you  = )
0
 
PhilippeRenaudAuthor Commented:
Yea i did it :)
0
 
PhilippeRenaudAuthor Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.