Results 1 to 7 of 7

Thread: [RESOLVED] Replace text inside brackets

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Resolved [RESOLVED] Replace text inside brackets

    Hi,
    stupid question, but how can I replace?
    Code:
    (THIS-IS-A-SENTENCE),but it is for 147th place in content.
    with
    Code:
    (NO-SENTENCE),but it is for 147th place in content.
    incl.brackets, not only text within brckts.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Replace text inside brackets

    Do you want to replace or remove what is inside of the PARENTHESES.

    Is there only one instance per line? Could there be a parenthesis for any other reason.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Replace text inside brackets

    Regex replace would probably work, but we need to know if that’s the only set of brackets in your text

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Replace text inside brackets

    Quote Originally Posted by .paul. View Post
    Regex replace would probably work, but we need to know if that’s the only set of brackets in your text

    Yes, only one set of brackets.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Replace text inside brackets

    Code:
    MsgBox(System.Text.RegularExpressions.Regex.Replace("(THIS-IS-A-SENTENCE),but it is for 147th place in content.", "\(.+\)", "(NO-SENTENCE)"))

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Replace text inside brackets

    Thanks paul, this works!

    Code:
    TextBox4.Text = (System.Text.RegularExpressions.Regex.Replace(TextBox4.Text, "\(.+\)", TextBox_5.Text))
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: [RESOLVED] Replace text inside brackets


Posting Permissions

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



Click Here to Expand Forum to Full Width