Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7972517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:53:21+00:00 2026-06-04T07:53:21+00:00

Using this in VB 2010: Imports System.Text.RegularExpressions Public Class Form1 Private Sub Button1_Click(ByVal sender

  • 0

Using this in VB 2010:

Imports System.Text.RegularExpressions

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim lines() As String = IO.File.ReadAllLines("filename.txt")
        Dim foundIndex As Integer = Array.FindIndex(lines, Function(l) l.StartsWith(TextBox1.Text)) 'assuming TextBox1.Text = the part of the line before the =
        lines(foundIndex) = Regex.Replace(lines(foundIndex), "(?<=" & TextBox1.Text & "=)\d+", TextBox2.Text) 'TextBox2.Text is the replacement number
        Stop
        'to rewrite the file:
        'IO.File.WriteAllLines("filename.txt", lines)
    End Sub
End Class

…but it keeps adding numbers after equals sign every time i save the text file.

I want it to replace everything on that line after equals sign.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:53:23+00:00Added an answer on June 4, 2026 at 7:53 am

    I executed your code and It works unchanged:

    Sub Main
         Dim lines() As String = IO.File.ReadAllLines("c:\temp\filename.txt")
         lines.Dump()
            Dim foundIndex As Integer = Array.FindIndex(lines, Function(l) l.StartsWith("blah")) 'assuming TextBox1.Text = the part of the line before the =
            foundIndex.Dump()
            lines(foundIndex) = Regex.Replace(lines(foundIndex), "(?<=blah=)[\d.e+]+", "replaced") 'TextBox2.Text is the replacement number
            IO.File.WriteAllLines("c:\temp\filename.txt", lines)
    End Sub
    

    If the file is

    test=456
    blah=456
    blah=just
    

    it will become

    test=456
    blah=replaced
    blah=just
    

    This is as you want it no?

    Update 1

    I replaced

    "(?<=blah=)\d+"
    

    With

    "(?<=blah=)[\d.]+"
    

    Update 2

    Regarding the issue with strings like “1e+007”. The part that matches the string after the “=” is currently [\d.]

    Remember that there was a problem with numbers that had the decimal point like 3.25? This was solved by adding the “.” to the character class [\d] so it becomes [\d.]
    Now anything that is a number “\d” and a “.” will match.

    The new issue is solved in the same way. Now “e” and “+” should also be matched. Get it? So the character class now becomes [\d.e+]

    Give it a go and let me know how it went.

    Now it should also be clear how to modify the regex to match “BGS_LOGO.BIK” If you can solve that you understand what’s going on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using this tutorial http://mpjexpress.blogspot.co.nz/2010/05/executing-and-debugging-mpj-express.html , text: steps 1,2,3 and video: steps between
I have compiled this using Visual Studio 2010 compiler and it has compiler error
Using Microsoft Visual Studio 2010: Can I write this type of macro in C?
I wrote this simple C code and compiled it using Visual Studio 2010, with
On this page: http://www.blackdownluxurylettings.co.uk/place_booking/2010-3-18,2 I am using an onchange event on the number of
I used this example (http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/) to upload file from android device to server, it
I was deploying an Azure instance using Visual Studio (2010) and i get this:
My problem is this one, I am using Sharepoint 2010, I have a form
Oh wow is this one annoying me. Using c#, winforms, visual studio 2010 ulti.
I have been sharing database variables using the following code: Namespace DataAccessVariables Public Class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.