Help manipulating my String

Hello EE,

I have a string like this:


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

so the string need to be at the end:


another example:

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

any idea ? (how to repert the digit then +1 on it etc..)
Who is Participating?
käµfm³d 👽Commented:

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

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);


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)
PhilippeRenaudAuthor Commented:
Hey kaufmed, related question :

how could we do both at the same time?  do you think its possible via the same Delegate maybe?
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.