Thanks... and now how do I...

Results 1 to 2 of 2

Thread: Thanks... and now how do I...

  1. #1
    Join Date
    Dec 1969

    Default Thanks... and now how do I...

    Thanks to a few excellent suggestions yesterday, I am almost completely through this problem of parsing through text sent to me from a system that is not very useful for the users. However, I have one last question that one of you guys can probably help with.<BR>I am passing a string from a Session(variable) and I need to run a regex function to find all values that meet the requirement Regex("104[0-9][0-9][0-9][0-9][0-9][0-9][0-9]")<BR>I can do this and find the values and print them to the page, but what I want to do is find them in the Session(variable) and reformat each instance using a formula. I am sure this is easy, I just can&#039;t seem to figure it out. Anyone have an idea how, if the user clicks a button, could this be run on the Session(variable) and change the value of each instance based on a formula?? Using vb and ASP.NET in VS.NET.

  2. #2
    Join Date
    Dec 1969

    Default RE: Thanks... and now how do I...

    Well, you can do it using the Regex.Replace and Regex.Match methods. For instance, I did this:<BR><BR>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> Dim lstrBigNum As String = "104123456715236541044567891"<BR> Dim digitregex As Regex = New Regex("104[0-9][0-9][0-9][0-9][0-9][0-9][0-9]")<BR> lstrBigNum = Regex.Replace(lstrBigNum, "104[0-9][0-9][0-9][0-9][0-9][0-9][0-9]", MyTest(Regex.Match(lstrBigNum, "104[0-9][0-9][0-9][0-9][0-9][0-9][0-9]").Value))<BR> lblTest.Text = lstrBigNum<BR> End Sub<BR><BR> Private Function MyTest(ByVal lstrValue As String) As String<BR> MyTest = "Test"<BR> End Function<BR><BR>When I&#039;m done the lblTest displays Test1523654Test. Just replace lstrBigNum with your session variable. Hope that helps.<BR><BR>Sara

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts